public static Script PayToScriptHash(Address addr) { List<ScriptElement> se = new List<ScriptElement>(); se.Add(new ScriptElement(OpCode.OP_HASH160)); se.Add(new ScriptElement(addr.ScriptHash)); se.Add(new ScriptElement(OpCode.OP_EQUAL)); return new Script(se.ToArray()); }
public static Script PayToPubKeyHash(Address addr) { List<ScriptElement> se = new List<ScriptElement>(); se.Add(new ScriptElement(OpCode.OP_DUP)); se.Add(new ScriptElement(OpCode.OP_HASH160)); se.Add(new ScriptElement(addr.PubKeyHash)); se.Add(new ScriptElement(OpCode.OP_EQUALVERIFY)); se.Add(new ScriptElement(OpCode.OP_CHECKSIG)); return new Script(se.ToArray()); }
public static Script PayToAddress(Address addr) { switch (addr.Type) { case Address.PUBKEYHASH: return PayToPubKeyHash(addr); case Address.SCRIPTHASH: return PayToScriptHash(addr); default: throw new ArgumentException("Invalid address"); } }