Skip to content

Commit fa3a655

Browse files
committed
fix comments
1 parent 31db9ff commit fa3a655

7 files changed

Lines changed: 44 additions & 67 deletions

File tree

CHANGELOG.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,32 @@ The format is loosely based on [Keep a Changelog](https://keepachangelog.com/en/
1111

1212
## [Unreleased]
1313

14+
### Added
15+
- Wallet:
16+
- Added support for Ledger hardware wallets (beta).
17+
18+
- Wallet RPC:
19+
- New value `ledger` in the `hardware_wallet` option for `wallet_create`, `wallet_recover` and `wallet_open` methods.
20+
21+
- Wallet CLI:
22+
- `wallet-create`/`wallet-recover`/`wallet-open` support the `ledger` subcommand, in addition to the existing
23+
`software` and `trezor`, which specifies the type of the wallet to operate on.
24+
25+
## [1.3.0] - 2026-04-09
26+
1427
### Added
1528
- Node RPC: new methods added - `chainstate_tokens_info`, `chainstate_orders_info_by_currencies`.
1629

1730
- Wallet RPC:
1831
- new methods added: `node_get_tokens_info`, `order_list_own`, `order_list_all_active`, `utxo_spend`.
19-
- new value `ledger` in the `hardware_wallet` option for `wallet_create`, `wallet_recover` and `wallet_open` methods.
2032

2133
- Wallet CLI:
2234
- the commands `order-create`, `order-fill`, `order-freeze`, `order-conclude`, `htlc-create-transaction` were added,
2335
mirroring their existing RPC counterparts.
2436
- other new commands added: `order-list-own`, `order-list-all-active`, `utxo-spend`, `htlc-generate-secret`,
2537
`htlc-calc-secret-hash`.
26-
- `wallet-create`/`wallet-recover`/`wallet-open` support the `ledger` subcommand, in addition to the existing
27-
`software` and `trezor`, which specifies the type of the wallet to operate on.
2838

2939
- Wallet:
30-
- Added support for Ledger hardware wallets (beta).
3140
- Now the wallet subscribes to events from the Mempool to include not yet confirmed transactions
3241
relevant to this wallet.
3342

api-server/api-server-common/src/storage/impls/in_memory/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ impl ApiServerInMemoryStorage {
889889

890890
Ok(self
891891
.locked_utxo_table
892-
.get(&outpoint)
892+
.get(outpoint)
893893
.and_then(|by_height| by_height.values().last())
894894
.map(|locked_utxo| {
895895
Utxo::new_with_info(locked_utxo.utxo_with_extra_info().clone(), None)

api-server/api-server-common/src/storage/impls/postgres/queries.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3342,7 +3342,7 @@ impl<'a, 'b> QueryFromConnection<'a, 'b> {
33423342
return Ok(Some(Utxo::new_with_info(output, spent)));
33433343
}
33443344

3345-
return Ok(None);
3345+
Ok(None)
33463346
}
33473347

33483348
pub async fn set_mempool_utxo(

api-server/scanner-lib/src/blockchain_state/mod.rs

Lines changed: 26 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ use common::{
3636
chain::{
3737
block::{timestamp::BlockTimestamp, ConsensusData},
3838
config::ChainConfig,
39+
htlc::HashedTimelockContract,
3940
make_delegation_id, make_order_id, make_token_id,
4041
output_value::OutputValue,
4142
signature::inputsig::{
@@ -74,6 +75,8 @@ pub enum BlockchainStateError {
7475
PoolNotFound,
7576
#[error("Order not found in DB")]
7677
OrderNotFound,
78+
#[error("Invalid HTLC signature in TX")]
79+
InvalidHtlcSignature,
7780
#[error("Id creation error: {0}")]
7881
IdCreationError(#[from] IdCreationError),
7982
}
@@ -348,24 +351,8 @@ impl<S: ApiServerStorage + Send + Sync> LocalBlockchainState for BlockchainState
348351
transaction_tokens.insert(token_id);
349352
}
350353
TxOutput::Htlc(output_value, htlc) => {
351-
let address = if let InputWitness::Standard(sig) = sig {
352-
let htlc_sig = AuthorizedHashedTimelockContractSpend::decode_all(
353-
&mut sig.raw_signature(),
354-
)
355-
.expect("proper signature");
356-
let dest = match htlc_sig {
357-
AuthorizedHashedTimelockContractSpend::Spend(_, _) => {
358-
htlc.spend_key
359-
}
360-
AuthorizedHashedTimelockContractSpend::Refund(_) => {
361-
htlc.refund_key
362-
}
363-
};
364-
Address::<Destination>::new(&self.chain_config, dest)
365-
.expect("Unable to encode destination")
366-
} else {
367-
panic!("Empty signature for htlc")
368-
};
354+
let address =
355+
htlc_destination(sig, *htlc, &self.chain_config).expect("valid tx");
369356
address_transactions.entry(address.clone()).or_default().insert(tx_id);
370357

371358
if let OutputValue::TokenV1(token_id, _) = output_value {
@@ -2098,25 +2085,8 @@ async fn update_tables_from_transaction_inputs<T: ApiServerStorageWrite>(
20982085
transaction_tokens.insert(token_id);
20992086
}
21002087
TxOutput::Htlc(output_value, htlc) => {
2101-
let address = if let InputWitness::Standard(sig) = sig {
2102-
let htlc_sig = AuthorizedHashedTimelockContractSpend::decode_all(
2103-
&mut sig.raw_signature(),
2104-
)
2105-
.expect("proper signature");
2106-
2107-
let dest = match htlc_sig {
2108-
AuthorizedHashedTimelockContractSpend::Spend(_, _) => {
2109-
htlc.spend_key
2110-
}
2111-
AuthorizedHashedTimelockContractSpend::Refund(_) => {
2112-
htlc.refund_key
2113-
}
2114-
};
2115-
Address::<Destination>::new(&chain_config, dest)
2116-
.expect("Unable to encode destination")
2117-
} else {
2118-
panic!("Empty signature for htlc")
2119-
};
2088+
let address =
2089+
htlc_destination(sig, *htlc, &chain_config).expect("valid tx");
21202090

21212091
address_transactions
21222092
.entry(address.clone())
@@ -3102,3 +3072,22 @@ async fn decrease_mempool_balance<T: ApiServerStorageWrite + ApiServerStorageRea
31023072
.await
31033073
.map_err(BlockchainStateError::StorageError)
31043074
}
3075+
3076+
fn htlc_destination(
3077+
sig: &InputWitness,
3078+
htlc: HashedTimelockContract,
3079+
chain_config: &ChainConfig,
3080+
) -> Result<Address<Destination>, BlockchainStateError> {
3081+
if let InputWitness::Standard(sig) = sig {
3082+
let htlc_sig = AuthorizedHashedTimelockContractSpend::decode_all(&mut sig.raw_signature())
3083+
.expect("proper signature");
3084+
3085+
let dest = match htlc_sig {
3086+
AuthorizedHashedTimelockContractSpend::Spend(_, _) => htlc.spend_key,
3087+
AuthorizedHashedTimelockContractSpend::Refund(_) => htlc.refund_key,
3088+
};
3089+
Ok(Address::<Destination>::new(chain_config, dest).expect("Unable to encode destination"))
3090+
} else {
3091+
Err(BlockchainStateError::InvalidHtlcSignature)
3092+
}
3093+
}

api-server/scanner-lib/src/sync/remote_node.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use chainstate::ChainInfo;
1717
use common::{
18-
chain::{Block, GenBlock, SignedTransaction, Transaction},
18+
chain::{Block, GenBlock, SignedTransaction},
1919
primitives::{BlockHeight, Id},
2020
};
2121
use mempool::FeeRate;
@@ -42,10 +42,6 @@ pub trait RemoteNode {
4242
) -> Result<Vec<Block>, Self::Error>;
4343

4444
async fn mempool_feerate_points(&self) -> Result<Vec<(usize, FeeRate)>, Self::Error>;
45-
async fn mempool_get_transaction(
46-
&self,
47-
tx_id: Id<Transaction>,
48-
) -> Result<Option<SignedTransaction>, Self::Error>;
4945
async fn mempool_get_transactions(&self) -> Result<Vec<SignedTransaction>, Self::Error>;
5046
}
5147

@@ -76,13 +72,6 @@ impl RemoteNode for NodeRpcClient {
7672
self.mempool_get_fee_rate_points().await
7773
}
7874

79-
async fn mempool_get_transaction(
80-
&self,
81-
tx_id: Id<Transaction>,
82-
) -> Result<Option<SignedTransaction>, Self::Error> {
83-
NodeInterface::mempool_get_transaction(self, tx_id).await
84-
}
85-
8675
async fn mempool_get_transactions(&self) -> Result<Vec<SignedTransaction>, Self::Error> {
8776
NodeInterface::mempool_get_transactions(self).await
8877
}

api-server/scanner-lib/src/sync/tests/mod.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,6 @@ impl RemoteNode for MockRemoteNode {
210210
)])
211211
}
212212

213-
async fn mempool_get_transaction(
214-
&self,
215-
_tx_id: Id<Transaction>,
216-
) -> Result<Option<SignedTransaction>, Self::Error> {
217-
Ok(None)
218-
}
219-
220213
async fn mempool_get_transactions(&self) -> Result<Vec<SignedTransaction>, Self::Error> {
221214
Ok(vec![])
222215
}

api-server/scanner-lib/src/sync/tx_dependency_ordering/dependency_graph.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,8 @@ fn tx_priority_order(tx: &SignedTransaction) -> TxPriorityOrder {
243243
}
244244

245245
for out in tx.transaction().outputs() {
246-
match out {
247-
TxOutput::DelegateStaking(_, _) => {
248-
priority = std::cmp::min(priority, TxPriorityOrder::DelegationStake);
249-
}
250-
_ => {}
246+
if let TxOutput::DelegateStaking(_, _) = out {
247+
priority = std::cmp::min(priority, TxPriorityOrder::DelegationStake);
251248
}
252249
}
253250

0 commit comments

Comments
 (0)