Как подписать транзакцию P2SH(P2WSH)?
var alice = new SafeAccount(id: 2); var aliceAddress = safe.GetAddress(index: 1, hdPathType: HdPathType.Receive, account: alice); var alicePrivate = safe.FindPrivateKey(aliceAddress, account: alice); // safe.GetPrivateKey(index: 1, hdPathType: HdPathType.Receive, account: alice); var david = new SafeAccount(id: 3); var davidAddress = safe.GetAddress(index: 1, hdPathType: HdPathType.Receive, account: david); var davidPrivate = safe.FindPrivateKey(davidAddress, account: david); Script redeemScript = PayToMultiSigTemplate.Instance.GenerateScriptPubKey( 2, alicePrivate.PrivateKey.PubKey, davidPrivate.PrivateKey.PubKey); var received = new Transaction(); received.Outputs.Add(new TxOut(Money.Coins(0.0021m), redeemScript.WitHash.ScriptPubKey.Hash.ScriptPubKey)); ScriptCoin bobAliceScriptCoin = received.Outputs.AsCoins().First().ToScriptCoin(redeemScript); var builder2 = new TransactionBuilder(); var tx2 = builder2 .AddCoins(bobAliceScriptCoin) .AddKeys(alicePrivate, davidPrivate) .Send(addressToSend, Money.Coins(0.002m)) .SetChange(aliceAddress) .SendFees(Money.Coins(0.0001m)) .BuildTransaction(true); Console.WriteLine(builder2.Verify(tx2));
Что я уже пробовал:
I would like to sign a P2SH(P2WSH) transaction but failed. Anyone can help to review the below codes?