public static byte[] CreateSignatureRedeemScript(ECPoint publicKey) { using (ScriptBuilder sb = new ScriptBuilder()) { sb.Push(publicKey.EncodePoint(true)); sb.Add(ScriptOp.OP_CHECKSIG); return(sb.ToArray()); } }
public static Contract CreateSignatureContract(ECPoint publicKey) { using (ScriptBuilder sb = new ScriptBuilder()) { sb.Push(publicKey.EncodePoint(true)); sb.Add(ScriptOp.OP_CHECKSIG); return(new Contract(sb.ToArray())); } }
public static TransactionOutput Create(Fixed8 value, string address) { if (address == null) { throw new ArgumentNullException(nameof(address)); } bool p2sh; UInt160 hash = Wallet.ToScriptHash(address, out p2sh); using (ScriptBuilder sb = new ScriptBuilder()) { if (p2sh) { sb.Add(ScriptOp.OP_HASH160); sb.Push(hash.ToArray()); sb.Add(ScriptOp.OP_EQUAL); } else { sb.Add(ScriptOp.OP_DUP); sb.Add(ScriptOp.OP_HASH160); sb.Push(hash.ToArray()); sb.Add(ScriptOp.OP_EQUALVERIFY); sb.Add(ScriptOp.OP_CHECKSIG); } return(new TransactionOutput { Value = value, Script = sb.ToArray() }); } }
public static byte[] CreateMultiSigRedeemScript(int m, params ECPoint[] publicKeys) { if (!(1 <= m && m <= publicKeys.Length && publicKeys.Length <= 1024)) { throw new ArgumentException(); } using (ScriptBuilder sb = new ScriptBuilder()) { sb.Push(m); foreach (ECPoint publicKey in publicKeys.OrderBy(p => p)) { sb.Push(publicKey.EncodePoint(true)); } sb.Push(publicKeys.Length); sb.Add(ScriptOp.OP_CHECKMULTISIG); return(sb.ToArray()); } }