Skip to content

Commit

Permalink
Add param to SelectedUtxosFeeRequest
Browse files Browse the repository at this point in the history
  • Loading branch information
lmuntaner committed Oct 1, 2024
1 parent 6acbb54 commit 5c54e80
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions src/backend/backend.did
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ type SelectedUtxosFeeRequest = record {
network : BitcoinNetwork;
amount_satoshis : nat64;
source_address : text;
min_confirmations : opt nat32;
};
type SelectedUtxosFeeResponse = record {
fee_satoshis : nat64;
Expand Down
6 changes: 5 additions & 1 deletion src/backend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,11 @@ async fn btc_select_user_utxos_fee(
let all_utxos = bitcoin_api::get_all_utxos(
params.network,
params.source_address,
Some(MIN_CONFIRMATIONS_ACCEPTED_BTC_TX),
Some(
params
.min_confirmations
.unwrap_or(MIN_CONFIRMATIONS_ACCEPTED_BTC_TX),
),
)
.await
.map_err(|msg| SelectedUtxosFeeError::InternalError { msg })?;
Expand Down
2 changes: 2 additions & 0 deletions src/backend/tests/it/bitcoin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ fn test_select_user_utxos_fee_returns_zero_when_user_has_insufficient_funds() {
amount_satoshis: 100_000_000u64,
source_address: "bcrt1qpg7udjvq7gx2fp480pgt4hnhj3qc4nhrkstc33".to_string(),
network: BitcoinNetwork::Regtest,
// Until bitcoin is supported in pocket-ic it only works with 1.
min_confirmations: Some(1),
};
let response = pic_setup.update::<Result<SelectedUtxosFeeResponse, SelectedUtxosFeeError>>(
caller,
Expand Down
1 change: 1 addition & 0 deletions src/declarations/backend/backend.did
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ type SelectedUtxosFeeRequest = record {
network : BitcoinNetwork;
amount_satoshis : nat64;
source_address : text;
min_confirmations : opt nat32;
};
type SelectedUtxosFeeResponse = record {
fee_satoshis : nat64;
Expand Down
1 change: 1 addition & 0 deletions src/declarations/backend/backend.did.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export interface SelectedUtxosFeeRequest {
network: BitcoinNetwork;
amount_satoshis: bigint;
source_address: string;
min_confirmations: [] | [number];
}
export interface SelectedUtxosFeeResponse {
fee_satoshis: bigint;
Expand Down
3 changes: 2 additions & 1 deletion src/declarations/backend/backend.factory.certified.did.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export const idlFactory = ({ IDL }) => {
const SelectedUtxosFeeRequest = IDL.Record({
network: BitcoinNetwork,
amount_satoshis: IDL.Nat64,
source_address: IDL.Text
source_address: IDL.Text,
min_confirmations: IDL.Opt(IDL.Nat32)
});
const Outpoint = IDL.Record({
txid: IDL.Vec(IDL.Nat8),
Expand Down
3 changes: 2 additions & 1 deletion src/declarations/backend/backend.factory.did.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ export const idlFactory = ({ IDL }) => {
const SelectedUtxosFeeRequest = IDL.Record({
network: BitcoinNetwork,
amount_satoshis: IDL.Nat64,
source_address: IDL.Text
source_address: IDL.Text,
min_confirmations: IDL.Opt(IDL.Nat32)
});
const Outpoint = IDL.Record({
txid: IDL.Vec(IDL.Nat8),
Expand Down
1 change: 1 addition & 0 deletions src/shared/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ pub mod bitcoin {
pub amount_satoshis: u64,
pub source_address: String,
pub network: BitcoinNetwork,
pub min_confirmations: Option<u32>,
}

#[derive(CandidType, Deserialize, Clone, Eq, PartialEq, Debug)]
Expand Down

0 comments on commit 5c54e80

Please sign in to comment.