@@ -351,7 +351,30 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
351351 setAddress.insert (rcp.address );
352352 ++nAddresses;
353353
354- CScript scriptPubKey = GetScriptForDestination (CBitcoinAddress (rcp.address .toStdString ()).Get ());
354+ CScript scriptPubKey;
355+ CBitcoinAddress out = CBitcoinAddress (rcp.address .toStdString ());
356+
357+ if (rcp.isP2CS ) {
358+ CBitcoinAddress ownerAdd;
359+ if (rcp.ownerAddress .isEmpty ()) {
360+ // Create new internal owner address
361+ if (!getNewAddress (ownerAdd).result )
362+ return CannotCreateInternalAddress;
363+ } else {
364+ ownerAdd = CBitcoinAddress (rcp.ownerAddress .toStdString ());
365+ }
366+
367+ CKeyID stakerId;
368+ CKeyID ownerId;
369+ if (!out.GetKeyID (stakerId) || !ownerAdd.GetKeyID (ownerId)) {
370+ return InvalidAddress;
371+ }
372+
373+ scriptPubKey = GetScriptForStakeDelegation (stakerId, ownerId);
374+ } else {
375+ // Regular P2PK or P2PKH
376+ scriptPubKey = GetScriptForDestination (out.Get ());
377+ }
355378 vecSend.push_back (std::pair<CScript, CAmount>(scriptPubKey, rcp.amount ));
356379
357380 total += rcp.amount ;
@@ -418,9 +441,11 @@ WalletModel::SendCoinsReturn WalletModel::sendCoins(WalletModelTransaction& tran
418441 return AnonymizeOnlyUnlocked;
419442 }
420443
444+ bool fColdStakingActive = sporkManager.IsSporkActive (SPORK_17_COLDSTAKING_ENFORCEMENT);
445+
421446 // Double check tx before do anything
422447 CValidationState state;
423- if (!CheckTransaction (*transaction.getTransaction (), true , true , state, true )){
448+ if (!CheckTransaction (*transaction.getTransaction (), true , true , state, true , fColdStakingActive )){
424449 return TransactionCommitFailed;
425450 }
426451
0 commit comments