Skip to content

Commit 95a84fa

Browse files
committed
fixup: use a real, already confirmed package to test submitpackage
1 parent c58b9c4 commit 95a84fa

3 files changed

Lines changed: 38 additions & 49 deletions

File tree

src/chain/electrum.rs

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -389,28 +389,6 @@ struct ElectrumRuntimeClient {
389389
logger: Arc<Logger>,
390390
}
391391

392-
fn dummy_transaction() -> Transaction {
393-
Transaction {
394-
version: bitcoin::transaction::Version::TWO,
395-
lock_time: bitcoin::absolute::LockTime::ZERO,
396-
input: vec![bitcoin::TxIn {
397-
previous_output: bitcoin::OutPoint {
398-
txid: bitcoin::Txid::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(
399-
[0u8; 32],
400-
)),
401-
vout: 0,
402-
},
403-
sequence: bitcoin::Sequence::MAX,
404-
script_sig: bitcoin::ScriptBuf::new(),
405-
witness: bitcoin::Witness::new(),
406-
}],
407-
output: vec![bitcoin::TxOut {
408-
script_pubkey: bitcoin::ScriptBuf::new(),
409-
value: bitcoin::Amount::ZERO,
410-
}],
411-
}
412-
}
413-
414392
impl ElectrumRuntimeClient {
415393
fn new(
416394
server_url: String, sync_config: ElectrumSyncConfig, runtime: Arc<Runtime>,
@@ -430,10 +408,12 @@ impl ElectrumRuntimeClient {
430408
})?,
431409
);
432410
if config.anchor_channels_config.is_some() {
433-
electrum_client.transaction_broadcast_package(&[dummy_transaction()]).map_err(|e| {
434-
log_error!(logger, "Electrum server does not support submit package: {:?}", e);
435-
Error::ConnectionFailed
436-
})?;
411+
electrum_client.transaction_broadcast_package(&super::dummy_package()).map_err(
412+
|e| {
413+
log_error!(logger, "Electrum server does not support submit package: {:?}", e);
414+
Error::ConnectionFailed
415+
},
416+
)?;
437417
}
438418
let bdk_electrum_client = Arc::new(BdkElectrumClient::new(Arc::clone(&electrum_client)));
439419
let tx_sync = Arc::new(

src/chain/esplora.rs

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,6 @@ pub(super) struct EsploraChainSource {
4040
node_metrics: Arc<RwLock<NodeMetrics>>,
4141
}
4242

43-
fn dummy_transaction() -> Transaction {
44-
Transaction {
45-
version: bitcoin::transaction::Version::TWO,
46-
lock_time: bitcoin::absolute::LockTime::ZERO,
47-
input: vec![bitcoin::TxIn {
48-
previous_output: bitcoin::OutPoint {
49-
txid: bitcoin::Txid::from_raw_hash(bitcoin::hashes::Hash::from_byte_array(
50-
[0u8; 32],
51-
)),
52-
vout: 0,
53-
},
54-
sequence: bitcoin::Sequence::MAX,
55-
script_sig: bitcoin::ScriptBuf::new(),
56-
witness: bitcoin::Witness::new(),
57-
}],
58-
output: vec![bitcoin::TxOut {
59-
script_pubkey: bitcoin::ScriptBuf::new(),
60-
value: bitcoin::Amount::ZERO,
61-
}],
62-
}
63-
}
64-
6543
impl EsploraChainSource {
6644
pub(crate) async fn new(
6745
server_url: String, headers: HashMap<String, String>, sync_config: EsploraSyncConfig,
@@ -81,7 +59,7 @@ impl EsploraChainSource {
8159
})?;
8260

8361
if config.anchor_channels_config.is_some() {
84-
esplora_client.submit_package(&[dummy_transaction()], None, None).await.map_err(
62+
esplora_client.submit_package(&super::dummy_package(), None, None).await.map_err(
8563
|e| {
8664
log_error!(logger, "Esplora server does not support submit package: {:?}", e);
8765
},

src/chain/mod.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,37 @@ use crate::runtime::Runtime;
2929
use crate::types::{Broadcaster, ChainMonitor, ChannelManager, DynStore, Sweeper, Wallet};
3030
use crate::{Error, NodeMetrics};
3131

32+
/// We use this parent-child TRUC package to make sure the configured chain source supports
33+
/// broadcasting packages via the `submitpackage` Bitcoin Core RPC.
34+
const PARENT_TXID: &str = "9a015f93fac6cb203c2b994e18b85176eb0354a22a468255516f3c6002d3f696";
35+
const PARENT_HEX: &str =
36+
"0300000000010160d0cdb72f2ddf719f40ca32f44614c67577fc75996140544003915683c34a310000000000fd\
37+
ffffff0201000000000000000451024e73876100000000000022512042731375894dad3b25092cd0f713dc5bee4\
38+
a71e30a95e1db3d880906d7eba1fa01409327942924218e4eb1635a7cce6706fcb37b8bbb61a2f0b86357356681\
39+
4e09419a3501e02252043bb237d479304632282fe9159db9e9a6ae6ec5bedea9f0f115a97b0e00";
40+
const CHILD_TXID: &str = "d011b3ff78cdfb8b93822639ea87771847936b04bb83afc8763a7c02a386ae26";
41+
const CHILD_HEX: &str =
42+
"0300000000010296f6d302603c6f515582462aa25403eb7651b8184e992b3c20cbc6fa935f019a0000000000ff\
43+
ffffff96f6d302603c6f515582462aa25403eb7651b8184e992b3c20cbc6fa935f019a0100000000fdffffff015\
44+
660000000000000225120ac18cd599a1be003595854e2eeec18dbe1c92d04b0ba05812d04445e3fcf16bc000140\
45+
1462a35808d77a164f0a23a84c4721d1545befd09ad19945bb8aa0ea5576953a9699038725f944b1bc429942ef4\
46+
7e6504a554babf022cb15db53be2d8c1dbfe5a97b0e00";
47+
48+
fn dummy_package() -> [bitcoin::Transaction; 2] {
49+
use bitcoin::consensus::Decodable;
50+
use bitcoin::hex::FromHex;
51+
use bitcoin::Transaction;
52+
let parent_tx_bytes = Vec::from_hex(PARENT_HEX).expect("read from a constant");
53+
let child_tx_bytes = Vec::from_hex(CHILD_HEX).expect("read from a constant");
54+
let parent =
55+
Transaction::consensus_decode(&mut &parent_tx_bytes[..]).expect("read from a constant");
56+
let child =
57+
Transaction::consensus_decode(&mut &child_tx_bytes[..]).expect("read from a constant");
58+
assert_eq!(parent.compute_txid().to_string(), PARENT_TXID);
59+
assert_eq!(child.compute_txid().to_string(), CHILD_TXID);
60+
[parent, child]
61+
}
62+
3263
pub(crate) enum WalletSyncStatus {
3364
Completed,
3465
InProgress { subscribers: tokio::sync::broadcast::Sender<Result<(), Error>> },

0 commit comments

Comments
 (0)