@@ -14,6 +14,7 @@ use bitcoin::blockdata::script::{Script,Builder};
1414use bitcoin:: blockdata:: opcodes;
1515use bitcoin:: blockdata:: transaction:: { TxIn , TxOut , OutPoint , Transaction , EcdsaSighashType } ;
1616use bitcoin:: util:: sighash;
17+ use bitcoin:: util:: address:: Payload ;
1718
1819use bitcoin:: hashes:: { Hash , HashEngine } ;
1920use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
@@ -25,11 +26,11 @@ use crate::ln::msgs::DecodeError;
2526use crate :: util:: ser:: { Readable , Writeable , Writer } ;
2627use crate :: util:: { byte_utils, transaction_utils} ;
2728
28- use bitcoin:: hash_types:: WPubkeyHash ;
2929use bitcoin:: secp256k1:: { SecretKey , PublicKey , Scalar } ;
3030use bitcoin:: secp256k1:: { Secp256k1 , ecdsa:: Signature , Message } ;
3131use bitcoin:: secp256k1:: Error as SecpError ;
3232use bitcoin:: { PackedLockTime , secp256k1, Sequence , Witness } ;
33+ use bitcoin:: PublicKey as BitcoinPublicKey ;
3334
3435use crate :: io;
3536use crate :: prelude:: * ;
@@ -1272,7 +1273,7 @@ impl CommitmentTransaction {
12721273 let script = if opt_anchors {
12731274 get_to_countersignatory_with_anchors_redeemscript ( & countersignatory_pubkeys. payment_point ) . to_v0_p2wsh ( )
12741275 } else {
1275- get_p2wpkh_redeemscript ( & countersignatory_pubkeys. payment_point )
1276+ Payload :: p2wpkh ( & BitcoinPublicKey :: new ( countersignatory_pubkeys. payment_point ) ) . unwrap ( ) . script_pubkey ( )
12761277 } ;
12771278 txouts. push ( (
12781279 TxOut {
@@ -1578,25 +1579,21 @@ pub fn get_commitment_transaction_number_obscure_factor(
15781579 | ( ( res[ 31 ] as u64 ) << 0 * 8 )
15791580}
15801581
1581- fn get_p2wpkh_redeemscript ( key : & PublicKey ) -> Script {
1582- Builder :: new ( ) . push_opcode ( opcodes:: all:: OP_PUSHBYTES_0 )
1583- . push_slice ( & WPubkeyHash :: hash ( & key. serialize ( ) ) [ ..] )
1584- . into_script ( )
1585- }
1586-
15871582#[ cfg( test) ]
15881583mod tests {
15891584 use super :: CounterpartyCommitmentSecrets ;
15901585 use crate :: { hex, chain} ;
15911586 use crate :: prelude:: * ;
1592- use crate :: ln:: chan_utils:: { get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, get_p2wpkh_redeemscript , CommitmentTransaction , TxCreationKeys , ChannelTransactionParameters , CounterpartyChannelTransactionParameters , HTLCOutputInCommitment } ;
1587+ use crate :: ln:: chan_utils:: { get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, CommitmentTransaction , TxCreationKeys , ChannelTransactionParameters , CounterpartyChannelTransactionParameters , HTLCOutputInCommitment } ;
15931588 use bitcoin:: secp256k1:: { PublicKey , SecretKey , Secp256k1 } ;
15941589 use crate :: util:: test_utils;
15951590 use crate :: chain:: keysinterface:: { KeysInterface , BaseSign } ;
15961591 use bitcoin:: { Network , Txid } ;
15971592 use bitcoin:: hashes:: Hash ;
15981593 use crate :: ln:: PaymentHash ;
15991594 use bitcoin:: hashes:: hex:: ToHex ;
1595+ use bitcoin:: util:: address:: Payload ;
1596+ use bitcoin:: PublicKey as BitcoinPublicKey ;
16001597
16011598 #[ test]
16021599 fn test_anchors ( ) {
@@ -1635,7 +1632,7 @@ mod tests {
16351632 & mut htlcs_with_aux, & channel_parameters. as_holder_broadcastable ( )
16361633 ) ;
16371634 assert_eq ! ( tx. built. transaction. output. len( ) , 2 ) ;
1638- assert_eq ! ( tx. built. transaction. output[ 1 ] . script_pubkey, get_p2wpkh_redeemscript ( & counterparty_pubkeys. payment_point) ) ;
1635+ assert_eq ! ( tx. built. transaction. output[ 1 ] . script_pubkey, Payload :: p2wpkh ( & BitcoinPublicKey :: new ( counterparty_pubkeys. payment_point) ) . unwrap ( ) . script_pubkey ( ) ) ;
16391636
16401637 // Generate broadcaster and counterparty outputs as well as two anchors
16411638 let tx = CommitmentTransaction :: new_with_auxiliary_htlc_data (
0 commit comments