Skip to content

Commit

Permalink
Merge pull request #36 from buffrr/wallet-confirmed-only
Browse files Browse the repository at this point in the history
Make default chain mainnet and add `--confirmed-only` option
  • Loading branch information
buffrr authored Nov 19, 2024
2 parents 8d34df9 + 975a377 commit 624dcf9
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
15 changes: 13 additions & 2 deletions node/src/bin/space-cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ use wallet::export::WalletExport;
#[command(version, about, long_about = None)]
pub struct Args {
/// Bitcoin network to use
#[arg(long, env = "SPACED_CHAIN")]
#[arg(long, env = "SPACED_CHAIN", default_value = "mainnet")]
chain: ExtendedNetwork,
/// Spaced RPC URL [default: based on specified chain]
#[arg(long)]
Expand Down Expand Up @@ -92,6 +92,8 @@ enum Commands {
/// Fee rate to use in sat/vB
#[arg(long, short)]
fee_rate: Option<u64>,
#[arg(long, short, default_value = "false")]
confirmed_only: bool,
},
/// Register a won auction
Register {
Expand Down Expand Up @@ -270,6 +272,7 @@ impl SpaceCli {
req: Option<RpcWalletRequest>,
bidouts: Option<u8>,
fee_rate: Option<u64>,
confirmed_only: bool,
) -> Result<(), ClientError> {
let fee_rate = fee_rate.map(|fee| FeeRate::from_sat_per_vb(fee).unwrap());
let result = self
Expand All @@ -285,6 +288,7 @@ impl SpaceCli {
fee_rate,
dust: self.dust,
force: self.force,
confirmed_only
},
)
.await?;
Expand Down Expand Up @@ -440,13 +444,15 @@ async fn handle_commands(
})),
None,
fee_rate,
false
)
.await?
}
Commands::Bid {
space,
amount,
fee_rate,
confirmed_only
} => {
cli.send_request(
Some(RpcWalletRequest::Bid(BidParams {
Expand All @@ -455,11 +461,12 @@ async fn handle_commands(
})),
None,
fee_rate,
confirmed_only
)
.await?
}
Commands::CreateBidOuts { pairs, fee_rate } => {
cli.send_request(None, Some(pairs), fee_rate).await?
cli.send_request(None, Some(pairs), fee_rate, false).await?
}
Commands::Register {
space,
Expand All @@ -473,6 +480,7 @@ async fn handle_commands(
})),
None,
fee_rate,
false
)
.await?
}
Expand All @@ -489,6 +497,7 @@ async fn handle_commands(
})),
None,
fee_rate,
false
)
.await?
}
Expand All @@ -504,6 +513,7 @@ async fn handle_commands(
})),
None,
fee_rate,
false
)
.await?
}
Expand Down Expand Up @@ -532,6 +542,7 @@ async fn handle_commands(
})),
None,
fee_rate,
false
)
.await?;
}
Expand Down
2 changes: 1 addition & 1 deletion node/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub struct Args {
#[arg(long, env = "SPACED_DATA_DIR")]
data_dir: Option<PathBuf>,
/// Network to use
#[arg(long, env = "SPACED_CHAIN")]
#[arg(long, env = "SPACED_CHAIN", default_value = "mainnet")]
chain: ExtendedNetwork,
/// Number of concurrent workers allowed during syncing
#[arg(short, long, env = "SPACED_JOBS", default_value = "8")]
Expand Down
1 change: 1 addition & 0 deletions node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ pub struct RpcWalletTxBuilder {
pub fee_rate: Option<FeeRate>,
pub dust: Option<Amount>,
pub force: bool,
pub confirmed_only: bool,
}

#[derive(Clone, Serialize, Deserialize)]
Expand Down
8 changes: 4 additions & 4 deletions node/src/wallets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,9 +603,9 @@ impl RpcWallet {
if tx.bidouts.is_some() {
builder = builder.bidouts(tx.bidouts.unwrap());
}
builder = builder.force(tx.force);

let mut bid_replacement = false;
builder = builder.force(tx.force);
let mut bid_replacement = tx.confirmed_only;

for req in tx.requests {
match req {
Expand Down Expand Up @@ -800,8 +800,8 @@ impl RpcWallet {
if rpc.message.contains("replacement-adds-unconfirmed") {
error_data.insert(
"hint".to_string(),
"Competing bid in mempool but wallet has no confirmed bid \
outputs (required to replace mempool bids)"
"Competing bid in mempool but wallet must use confirmed bidouts and funding \
outputs to replace it. Try --confirmed-only"
.to_string(),
);
}
Expand Down

0 comments on commit 624dcf9

Please sign in to comment.