/// Generates a script pubkey spending to this [Payload].
Generates a script pubkey spending to this [Payload].
Generates a script pubkey spending to this [ Payload ] .
pub fn script_pubkey(&self) -> script::Script {
        match *self {
            Payload::PubkeyHash(ref hash) => script::Builder::new()
                .push_opcode(opcodes::all::OP_DUP)
                .push_opcode(opcodes::all::OP_HASH160)
                .push_slice(&hash[..])
                .push_opcode(opcodes::all::OP_EQUALVERIFY)
                .push_opcode(opcodes::all::OP_CHECKSIG),
            Payload::ScriptHash(ref hash) => script::Builder::new()
                .push_opcode(opcodes::all::OP_HASH160)
                .push_slice(&hash[..])
                .push_opcode(opcodes::all::OP_EQUAL),
            Payload::WitnessProgram {
                version: ver,
                program: ref prog,
            } => {
                assert!(ver.to_u8() <= 16);
                let mut verop = ver.to_u8();
                if verop > 0 {
                    verop = 0x50 + verop;
                }
                script::Builder::new().push_opcode(verop.into()).push_slice(&prog)
            }
        }
        .into_script()
    }
pub fn script_pubkey ( & self ) -> script :: Script { match * self { Payload :: PubkeyHash ( ref hash ) => script :: Builder :: new ( ) . push_opcode ( opcodes :: all :: OP_DUP ) . push_opcode ( opcodes :: all :: OP_HASH160 ) . push_slice ( & hash [ .. ] ) . push_opcode ( opcodes :: all :: OP_EQUALVERIFY ) . push_opcode ( opcodes :: all :: OP_CHECKSIG ) , Payload :: ScriptHash ( ref hash ) => script :: Builder :: new ( ) . push_opcode ( opcodes :: all :: OP_HASH160 ) . push_slice ( & hash [ .. ] ) . push_opcode ( opcodes :: all :: OP_EQUAL ) , Payload :: WitnessProgram { version : ver , program : ref prog , } => { assert ! ( ver to_u8 ( ) 16 ) ; let mut verop = ver . to_u8 ( ) ; if verop > 0 { verop = 0x50 + verop ; } script :: Builder :: new ( ) . push_opcode ( verop . into ( ) ) . push_slice ( & prog ) } } . into_script ( ) }
Generates a script pubkey spending to this [Payload].
Generates a script pubkey spending to this [ Payload ] .
&self