@@ -14,6 +14,7 @@ use bitcoin::blockdata::script::{Script,Builder};
14
14
use bitcoin:: blockdata:: opcodes;
15
15
use bitcoin:: blockdata:: transaction:: { TxIn , TxOut , OutPoint , Transaction , EcdsaSighashType } ;
16
16
use bitcoin:: util:: sighash;
17
+ use bitcoin:: util:: address:: Payload ;
17
18
18
19
use bitcoin:: hashes:: { Hash , HashEngine } ;
19
20
use bitcoin:: hashes:: sha256:: Hash as Sha256 ;
@@ -25,11 +26,11 @@ use crate::ln::msgs::DecodeError;
25
26
use crate :: util:: ser:: { Readable , Writeable , Writer } ;
26
27
use crate :: util:: { byte_utils, transaction_utils} ;
27
28
28
- use bitcoin:: hash_types:: WPubkeyHash ;
29
29
use bitcoin:: secp256k1:: { SecretKey , PublicKey , Scalar } ;
30
30
use bitcoin:: secp256k1:: { Secp256k1 , ecdsa:: Signature , Message } ;
31
31
use bitcoin:: secp256k1:: Error as SecpError ;
32
32
use bitcoin:: { PackedLockTime , secp256k1, Sequence , Witness } ;
33
+ use bitcoin:: PublicKey as BitcoinPublicKey ;
33
34
34
35
use crate :: io;
35
36
use crate :: prelude:: * ;
@@ -1279,7 +1280,7 @@ impl CommitmentTransaction {
1279
1280
let script = if opt_anchors {
1280
1281
get_to_countersignatory_with_anchors_redeemscript ( & countersignatory_pubkeys. payment_point ) . to_v0_p2wsh ( )
1281
1282
} else {
1282
- get_p2wpkh_redeemscript ( & countersignatory_pubkeys. payment_point )
1283
+ Payload :: p2wpkh ( & BitcoinPublicKey :: new ( countersignatory_pubkeys. payment_point ) ) . unwrap ( ) . script_pubkey ( )
1283
1284
} ;
1284
1285
txouts. push ( (
1285
1286
TxOut {
@@ -1585,25 +1586,21 @@ pub fn get_commitment_transaction_number_obscure_factor(
1585
1586
| ( ( res[ 31 ] as u64 ) << 0 * 8 )
1586
1587
}
1587
1588
1588
- fn get_p2wpkh_redeemscript ( key : & PublicKey ) -> Script {
1589
- Builder :: new ( ) . push_opcode ( opcodes:: all:: OP_PUSHBYTES_0 )
1590
- . push_slice ( & WPubkeyHash :: hash ( & key. serialize ( ) ) [ ..] )
1591
- . into_script ( )
1592
- }
1593
-
1594
1589
#[ cfg( test) ]
1595
1590
mod tests {
1596
1591
use super :: CounterpartyCommitmentSecrets ;
1597
1592
use crate :: { hex, chain} ;
1598
1593
use crate :: prelude:: * ;
1599
- use crate :: ln:: chan_utils:: { get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, get_p2wpkh_redeemscript , CommitmentTransaction , TxCreationKeys , ChannelTransactionParameters , CounterpartyChannelTransactionParameters , HTLCOutputInCommitment } ;
1594
+ use crate :: ln:: chan_utils:: { get_htlc_redeemscript, get_to_countersignatory_with_anchors_redeemscript, CommitmentTransaction , TxCreationKeys , ChannelTransactionParameters , CounterpartyChannelTransactionParameters , HTLCOutputInCommitment } ;
1600
1595
use bitcoin:: secp256k1:: { PublicKey , SecretKey , Secp256k1 } ;
1601
1596
use crate :: util:: test_utils;
1602
1597
use crate :: chain:: keysinterface:: { KeysInterface , BaseSign } ;
1603
1598
use bitcoin:: { Network , Txid } ;
1604
1599
use bitcoin:: hashes:: Hash ;
1605
1600
use crate :: ln:: PaymentHash ;
1606
1601
use bitcoin:: hashes:: hex:: ToHex ;
1602
+ use bitcoin:: util:: address:: Payload ;
1603
+ use bitcoin:: PublicKey as BitcoinPublicKey ;
1607
1604
1608
1605
#[ test]
1609
1606
fn test_anchors ( ) {
@@ -1642,7 +1639,7 @@ mod tests {
1642
1639
& mut htlcs_with_aux, & channel_parameters. as_holder_broadcastable ( )
1643
1640
) ;
1644
1641
assert_eq ! ( tx. built. transaction. output. len( ) , 2 ) ;
1645
- assert_eq ! ( tx. built. transaction. output[ 1 ] . script_pubkey, get_p2wpkh_redeemscript ( & counterparty_pubkeys. payment_point) ) ;
1642
+ assert_eq ! ( tx. built. transaction. output[ 1 ] . script_pubkey, Payload :: p2wpkh ( & BitcoinPublicKey :: new ( counterparty_pubkeys. payment_point) ) . unwrap ( ) . script_pubkey ( ) ) ;
1646
1643
1647
1644
// Generate broadcaster and counterparty outputs as well as two anchors
1648
1645
let tx = CommitmentTransaction :: new_with_auxiliary_htlc_data (
0 commit comments