Skip to content
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

Merge bitcoindevkit/bdk-cli#99: The Great Reset #107

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Rewrite relevant doc comments as `structopt` help document.
- Update `bdk` and `bdk-reserves` to v0.19.0.
- Change default database to `sqlite`.
- Add the add_data option to create_tx to create an op_return output.

## [0.5.0]

Expand Down
18 changes: 18 additions & 0 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,22 @@ pub enum OfflineWalletSubCommand {
/// Selects which policy should be used to satisfy the internal descriptor
#[structopt(name = "INT_POLICY", long = "internal_policy")]
internal_policy: Option<String>,
/// Add string as an output using OP_RETURN
#[structopt(
name = "ADD_STRING",
long = "add_string",
short = "s",
conflicts_with = "ADD_DATA"
)]
add_string: Option<String>,
/// Add arbitrary data (max 80-bytes) as an output using OP_RETURN
#[structopt(
name = "ADD_DATA",
long = "add_data",
short = "o",
conflicts_with = "ADD_STRING"
)]
add_data: Option<String>,
},
/// Bumps the fees of an RBF transaction
BumpFee {
Expand Down Expand Up @@ -944,6 +960,8 @@ mod test {
fee_rate: None,
external_policy: None,
internal_policy: None,
add_data: None,
add_string: None,
}),
},
};
Expand Down
9 changes: 9 additions & 0 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ where
fee_rate,
external_policy,
internal_policy,
add_data,
add_string,
} => {
let mut tx_builder = wallet.build_tx();

Expand Down Expand Up @@ -154,6 +156,13 @@ where
tx_builder.unspendable(unspendable);
}

if let Some(base64_data) = add_data {
let op_return_data = base64::decode(&base64_data).unwrap();
tx_builder.add_data(op_return_data.as_slice());
} else if let Some(string_data) = add_string {
tx_builder.add_data(string_data.as_bytes());
}

let policies = vec![
external_policy.map(|p| (p, KeychainKind::External)),
internal_policy.map(|p| (p, KeychainKind::Internal)),
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.