-
Notifications
You must be signed in to change notification settings - Fork 158
Follow-ups to #660 #992
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Follow-ups to #660 #992
Changes from all commits
4e7516b
3da69d8
05efb2f
670d952
052303a
6fc65fa
00826a1
10b3030
62bf391
86bfd98
35d0a28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -31,19 +31,20 @@ use crate::{Error, PersistedNodeMetrics}; | |
|
|
||
| /// We use this parent-child TRUC package to make sure the configured chain source supports | ||
| /// broadcasting packages via the `submitpackage` Bitcoin Core RPC. | ||
| const PARENT_TXID: &str = "9a015f93fac6cb203c2b994e18b85176eb0354a22a468255516f3c6002d3f696"; | ||
| const DUMMY_PACKAGE_EXPECTED_ERROR: &str = "bad-txns-inputs-missingorspent"; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, matching on the exact string seems not very robust. Seems some minor change in how Bitcoin Core handles errors could lead to LDK Node not starting anymore. As mentioned on #660 (comment), maybe we just need to accept that we currently don't have a good way of checking all backends support v29+? Should we drop this commit?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could totally see us dropping this commit. Here's my argument against dropping it:
|
||
| const PARENT_TXID: &str = "11105ba7c94f2fdc1b870a9fbdb136ca006bcf598c372548a1a3051001f3238f"; | ||
| const PARENT_HEX: &str = | ||
| "0300000000010160d0cdb72f2ddf719f40ca32f44614c67577fc75996140544003915683c34a310000000000fd\ | ||
| "0300000000010160d0cdb72f2ddf719f40ca32f44614c67577fc75996140544003915683c34a310000000000ff\ | ||
| ffffff0201000000000000000451024e73876100000000000022512042731375894dad3b25092cd0f713dc5bee4\ | ||
| a71e30a95e1db3d880906d7eba1fa01409327942924218e4eb1635a7cce6706fcb37b8bbb61a2f0b86357356681\ | ||
| 4e09419a3501e02252043bb237d479304632282fe9159db9e9a6ae6ec5bedea9f0f115a97b0e00"; | ||
| const CHILD_TXID: &str = "d011b3ff78cdfb8b93822639ea87771847936b04bb83afc8763a7c02a386ae26"; | ||
| 4e09419a3501e02252043bb237d479304632282fe9159db9e9a6ae6ec5bedea9f0f11500000000"; | ||
| const CHILD_TXID: &str = "6a051464dbf0534a060a61355a6a971559de004795328f8dfd19f3197f9bb4b0"; | ||
| const CHILD_HEX: &str = | ||
| "0300000000010296f6d302603c6f515582462aa25403eb7651b8184e992b3c20cbc6fa935f019a0000000000ff\ | ||
| ffffff96f6d302603c6f515582462aa25403eb7651b8184e992b3c20cbc6fa935f019a0100000000fdffffff015\ | ||
| "030000000001028f23f3011005a3a14825378c59cf6b00ca36b1bd9f0a871bdc2f4fc9a75b10110000000000ff\ | ||
| ffffff8f23f3011005a3a14825378c59cf6b00ca36b1bd9f0a871bdc2f4fc9a75b10110100000000ffffffff015\ | ||
| 660000000000000225120ac18cd599a1be003595854e2eeec18dbe1c92d04b0ba05812d04445e3fcf16bc000140\ | ||
| 1462a35808d77a164f0a23a84c4721d1545befd09ad19945bb8aa0ea5576953a9699038725f944b1bc429942ef4\ | ||
| 7e6504a554babf022cb15db53be2d8c1dbfe5a97b0e00"; | ||
| 7e6504a554babf022cb15db53be2d8c1dbfe500000000"; | ||
|
|
||
| fn dummy_package() -> [bitcoin::Transaction; 2] { | ||
| use bitcoin::consensus::Decodable; | ||
|
|
@@ -55,11 +56,27 @@ fn dummy_package() -> [bitcoin::Transaction; 2] { | |
| Transaction::consensus_decode(&mut &parent_tx_bytes[..]).expect("read from a constant"); | ||
| let child = | ||
| Transaction::consensus_decode(&mut &child_tx_bytes[..]).expect("read from a constant"); | ||
| assert_eq!(parent.compute_txid().to_string(), PARENT_TXID); | ||
| assert_eq!(child.compute_txid().to_string(), CHILD_TXID); | ||
| let [parent_txid, child_txid] = dummy_package_txids(); | ||
| assert_eq!(parent.compute_txid(), parent_txid); | ||
| assert_eq!(child.compute_txid(), child_txid); | ||
| assert_eq!(parent.lock_time, bitcoin::absolute::LockTime::ZERO); | ||
| assert_eq!(child.lock_time, bitcoin::absolute::LockTime::ZERO); | ||
| assert!(parent | ||
| .input | ||
| .iter() | ||
| .chain(child.input.iter()) | ||
| .all(|input| input.sequence == bitcoin::Sequence::MAX)); | ||
| assert!(child.input.iter().all(|input| input.previous_output.txid == parent.compute_txid())); | ||
| [parent, child] | ||
| } | ||
|
|
||
| fn dummy_package_txids() -> [Txid; 2] { | ||
| [ | ||
| PARENT_TXID.parse().expect("read from a constant"), | ||
| CHILD_TXID.parse().expect("read from a constant"), | ||
| ] | ||
| } | ||
|
|
||
| pub(crate) enum WalletSyncStatus { | ||
| Completed, | ||
| InProgress { subscribers: tokio::sync::broadcast::Sender<Result<(), Error>> }, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,10 @@ pub use lightning_liquidity::lsps0::ser::LSPSDateTime; | |
| pub use lightning_liquidity::lsps1::msgs::{ | ||
| LSPS1ChannelInfo, LSPS1OrderId, LSPS1OrderParams, LSPS1PaymentState, | ||
| }; | ||
| use lightning_types::features::{InitFeatures as LdkInitFeatures, NodeFeatures as LdkNodeFeatures}; | ||
| use lightning_types::features::{ | ||
| ChannelTypeFeatures as LdkChannelTypeFeatures, InitFeatures as LdkInitFeatures, | ||
| NodeFeatures as LdkNodeFeatures, | ||
| }; | ||
| pub use lightning_types::payment::{PaymentHash, PaymentPreimage, PaymentSecret}; | ||
| pub use lightning_types::string::UntrustedString; | ||
| use vss_client::headers::{ | ||
|
|
@@ -1817,6 +1820,102 @@ impl From<LdkNodeFeatures> for NodeFeatures { | |
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, uniffi::Object)] | ||
| #[uniffi::export(Debug, Eq)] | ||
| pub struct ChannelTypeFeatures { | ||
| pub(crate) inner: LdkChannelTypeFeatures, | ||
| } | ||
|
|
||
| #[uniffi::export] | ||
| impl ChannelTypeFeatures { | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Codex:
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done below. |
||
| /// Constructs channel type features from big-endian BOLT 9 encoded bytes. | ||
| #[uniffi::constructor] | ||
| pub fn from_bytes(bytes: &[u8]) -> Self { | ||
| Self { inner: LdkChannelTypeFeatures::from_be_bytes(bytes.to_vec()) } | ||
| } | ||
|
|
||
| /// Returns the BOLT 9 big-endian encoded representation of these features. | ||
| pub fn to_bytes(&self) -> Vec<u8> { | ||
| self.inner.encode() | ||
| } | ||
|
|
||
| /// Whether this channel type advertises support for `option_static_remotekey`. | ||
| pub fn supports_static_remote_key(&self) -> bool { | ||
| self.inner.supports_static_remote_key() | ||
| } | ||
|
|
||
| /// Whether this channel type requires `option_static_remotekey`. | ||
| pub fn requires_static_remote_key(&self) -> bool { | ||
| self.inner.requires_static_remote_key() | ||
| } | ||
|
|
||
| /// Whether this channel type advertises support for `option_anchors_zero_fee_htlc_tx`. | ||
| pub fn supports_anchors_zero_fee_htlc_tx(&self) -> bool { | ||
| self.inner.supports_anchors_zero_fee_htlc_tx() | ||
| } | ||
|
|
||
| /// Whether this channel type requires `option_anchors_zero_fee_htlc_tx`. | ||
| pub fn requires_anchors_zero_fee_htlc_tx(&self) -> bool { | ||
| self.inner.requires_anchors_zero_fee_htlc_tx() | ||
| } | ||
|
|
||
| /// Whether this channel type advertises support for `option_anchors_nonzero_fee_htlc_tx`. | ||
| pub fn supports_anchors_nonzero_fee_htlc_tx(&self) -> bool { | ||
| self.inner.supports_anchors_nonzero_fee_htlc_tx() | ||
| } | ||
|
|
||
| /// Whether this channel type requires `option_anchors_nonzero_fee_htlc_tx`. | ||
| pub fn requires_anchors_nonzero_fee_htlc_tx(&self) -> bool { | ||
| self.inner.requires_anchors_nonzero_fee_htlc_tx() | ||
| } | ||
|
|
||
| /// Whether this channel type advertises support for `option_taproot`. | ||
| pub fn supports_taproot(&self) -> bool { | ||
| self.inner.supports_taproot() | ||
| } | ||
|
|
||
| /// Whether this channel type requires `option_taproot`. | ||
| pub fn requires_taproot(&self) -> bool { | ||
| self.inner.requires_taproot() | ||
| } | ||
|
|
||
| /// Whether this channel type advertises support for `option_scid_alias`. | ||
| pub fn supports_scid_privacy(&self) -> bool { | ||
| self.inner.supports_scid_privacy() | ||
| } | ||
|
|
||
| /// Whether this channel type requires `option_scid_alias`. | ||
| pub fn requires_scid_privacy(&self) -> bool { | ||
| self.inner.requires_scid_privacy() | ||
| } | ||
|
|
||
| /// Whether this channel type advertises support for `option_zeroconf`. | ||
| pub fn supports_zero_conf(&self) -> bool { | ||
| self.inner.supports_zero_conf() | ||
| } | ||
|
|
||
| /// Whether this channel type requires `option_zeroconf`. | ||
| pub fn requires_zero_conf(&self) -> bool { | ||
| self.inner.requires_zero_conf() | ||
| } | ||
|
|
||
| /// Whether this channel type advertises support for `option_zero_fee_commitments`. | ||
| pub fn supports_anchor_zero_fee_commitments(&self) -> bool { | ||
| self.inner.supports_anchor_zero_fee_commitments() | ||
| } | ||
|
|
||
| /// Whether this channel type requires `option_zero_fee_commitments`. | ||
| pub fn requires_anchor_zero_fee_commitments(&self) -> bool { | ||
| self.inner.requires_anchor_zero_fee_commitments() | ||
| } | ||
| } | ||
|
|
||
| impl From<LdkChannelTypeFeatures> for ChannelTypeFeatures { | ||
| fn from(features: LdkChannelTypeFeatures) -> Self { | ||
| Self { inner: features } | ||
| } | ||
| } | ||
|
|
||
| #[derive(Debug, Clone, PartialEq, Eq, uniffi::Object)] | ||
| #[uniffi::export(Debug, Eq)] | ||
| pub struct InitFeatures { | ||
|
|
@@ -2191,6 +2290,27 @@ mod tests { | |
| (ldk_invoice, wrapped_invoice) | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_channel_type_feature_accessors() { | ||
| let mut optional = LdkChannelTypeFeatures::empty(); | ||
| optional.set_scid_privacy_optional(); | ||
| optional.set_zero_conf_optional(); | ||
| let optional = ChannelTypeFeatures::from(optional); | ||
| assert!(optional.supports_scid_privacy()); | ||
| assert!(!optional.requires_scid_privacy()); | ||
| assert!(optional.supports_zero_conf()); | ||
| assert!(!optional.requires_zero_conf()); | ||
|
|
||
| let mut required = LdkChannelTypeFeatures::empty(); | ||
| required.set_scid_privacy_required(); | ||
| required.set_zero_conf_required(); | ||
| let required = ChannelTypeFeatures::from(required); | ||
| assert!(required.supports_scid_privacy()); | ||
| assert!(required.requires_scid_privacy()); | ||
| assert!(required.supports_zero_conf()); | ||
| assert!(required.requires_zero_conf()); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_invoice_description_conversion() { | ||
| let hash = "09d08d4865e8af9266f6cc7c0ae23a1d6bf868207cf8f7c5979b9f6ed850dfb0".to_string(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We map 400 here to ChainSourceNotSupported because Bitcoin Core v26 returns a RPC error when submitting the dummy package, which maps to error code 400.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grrr, this is all very brittle. I can't wait to drop all of this logic again once we can just assume
submitpackageis available if we have any chain source at all.