コード例 #1
0
 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()
         };
     }
 }