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

Add short flags #1102

Merged
merged 6 commits into from
Dec 29, 2022
Merged
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
2 changes: 1 addition & 1 deletion docs/src/guides/inscriptions.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ Creating Inscriptions
To create an inscription with the contents of `FILE`, run:

```
ord --signet wallet inscribe --file FILE
ord --signet wallet inscribe FILE
```

Ord will output two transactions IDs, one for the commit transaction, and one
Expand Down
27 changes: 24 additions & 3 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ pub(crate) struct Options {
pub(crate) index: Option<PathBuf>,
#[clap(long, help = "Index current location of all satoshis.")]
pub(crate) index_sats: bool,
#[clap(long, help = "Use regtest.")]
#[clap(long, short, help = "Use regtest.")]
regtest: bool,
#[clap(long, help = "Connect to Bitcoin Core RPC at <RPC_URL>.")]
rpc_url: Option<String>,
#[clap(long, help = "Use signet.")]
#[clap(long, short, help = "Use signet.")]
signet: bool,
#[clap(long, help = "Use testnet.")]
#[clap(long, short, help = "Use testnet.")]
testnet: bool,
}

Expand Down Expand Up @@ -405,6 +405,13 @@ mod tests {
.chain(),
Chain::Signet
);
assert_eq!(
Arguments::try_parse_from(["ord", "-s", "index"])
.unwrap()
.options
.chain(),
Chain::Signet
);

Arguments::try_parse_from(["ord", "--regtest", "--chain", "signet", "index"]).unwrap_err();
assert_eq!(
Expand All @@ -414,6 +421,13 @@ mod tests {
.chain(),
Chain::Regtest
);
assert_eq!(
Arguments::try_parse_from(["ord", "-r", "index"])
.unwrap()
.options
.chain(),
Chain::Regtest
);

Arguments::try_parse_from(["ord", "--testnet", "--chain", "signet", "index"]).unwrap_err();
assert_eq!(
Expand All @@ -423,5 +437,12 @@ mod tests {
.chain(),
Chain::Testnet
);
assert_eq!(
Arguments::try_parse_from(["ord", "-t", "index"])
.unwrap()
.options
.chain(),
Chain::Testnet
);
}
}
2 changes: 1 addition & 1 deletion src/subcommand/wallet/inscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use {
pub(crate) struct Inscribe {
#[clap(long, help = "Inscribe <SATPOINT>")]
satpoint: Option<SatPoint>,
#[clap(long, help = "Inscribe sat with contents of <FILE>")]
#[clap(help = "Inscribe sat with contents of <FILE>")]
file: PathBuf,
}

Expand Down
2 changes: 1 addition & 1 deletion tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ fn create_inscription(rpc_server: &test_bitcoincore_rpc::Handle, filename: &str)
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

let stdout = CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file {filename}"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 {filename}"
))
.write(filename, "HELLOWORLD")
.rpc_server(rpc_server)
Expand Down
10 changes: 5 additions & 5 deletions tests/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ fn inscription_page() {
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

let stdout = CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file hello.txt"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 hello.txt"
))
.write("hello.txt", "HELLOWORLD")
.rpc_server(&rpc_server)
Expand Down Expand Up @@ -81,7 +81,7 @@ fn inscription_appears_on_reveal_transaction_page() {
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

let stdout = CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file hello.txt"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 hello.txt"
))
.write("hello.txt", "HELLOWORLD")
.rpc_server(&rpc_server)
Expand All @@ -104,7 +104,7 @@ fn inscription_page_after_send() {
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

let stdout = CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file hello.txt"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 hello.txt"
))
.write("hello.txt", "HELLOWORLD")
.rpc_server(&rpc_server)
Expand Down Expand Up @@ -156,7 +156,7 @@ fn inscription_content() {
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

let stdout = CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file hello.txt"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 hello.txt"
))
.write("hello.txt", "HELLOWORLD")
.rpc_server(&rpc_server)
Expand Down Expand Up @@ -244,7 +244,7 @@ fn inscriptions_page() {
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

let stdout = CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file hello.txt"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 hello.txt"
))
.write("hello.txt", "HELLOWORLD")
.rpc_server(&rpc_server)
Expand Down
61 changes: 29 additions & 32 deletions tests/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fn send_works_on_signet() {
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

let stdout = CommandBuilder::new(format!(
"--chain signet --index-sats wallet inscribe --satpoint {txid}:0:0 --file degenerate.png"
"--chain signet --index-sats wallet inscribe --satpoint {txid}:0:0 degenerate.png"
))
.write("degenerate.png", [1; 520])
.rpc_server(&rpc_server)
Expand Down Expand Up @@ -124,7 +124,7 @@ fn send_inscribed_sat() {
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

let stdout = CommandBuilder::new(format!(
"--chain signet --index-sats wallet inscribe --satpoint {txid}:0:0 --file degenerate.png"
"--chain signet --index-sats wallet inscribe --satpoint {txid}:0:0 degenerate.png"
))
.write("degenerate.png", [1; 520])
.rpc_server(&rpc_server)
Expand Down Expand Up @@ -237,7 +237,7 @@ fn inscribe() {
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

let stdout = CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file hello.txt"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 hello.txt"
))
.write("hello.txt", "HELLOWORLD")
.rpc_server(&rpc_server)
Expand All @@ -262,13 +262,11 @@ fn inscribe_forbidden_on_mainnet() {
let rpc_server = test_bitcoincore_rpc::spawn_with(Network::Bitcoin, "ord");
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

CommandBuilder::new(format!(
"wallet inscribe --satpoint {txid}:0:0 --file hello.txt"
))
.rpc_server(&rpc_server)
.expected_exit_code(1)
.expected_stderr("error: `ord wallet inscribe` is unstable and not yet supported on mainnet.\n")
.run();
CommandBuilder::new(format!("wallet inscribe --satpoint {txid}:0:0 hello.txt"))
.rpc_server(&rpc_server)
.expected_exit_code(1)
.expected_stderr("error: `ord wallet inscribe` is unstable and not yet supported on mainnet.\n")
.run();
}

#[test]
Expand All @@ -277,7 +275,7 @@ fn inscribe_unknown_file_extension() {
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file pepe.xyz"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 pepe.xyz"
))
.write("pepe.xyz", [1; 520])
.rpc_server(&rpc_server)
Expand All @@ -292,7 +290,7 @@ fn inscribe_png() {
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

let stdout = CommandBuilder::new(format!(
"--chain regtest --index-sats wallet inscribe --satpoint {txid}:0:0 --file degenerate.png"
"--chain regtest --index-sats wallet inscribe --satpoint {txid}:0:0 degenerate.png"
))
.write("degenerate.png", [1; 520])
.rpc_server(&rpc_server)
Expand All @@ -319,7 +317,7 @@ fn inscribe_exceeds_push_byte_limit() {
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

CommandBuilder::new(format!(
"--chain signet wallet inscribe --satpoint {txid}:0:0 --file degenerate.png"
"--chain signet wallet inscribe --satpoint {txid}:0:0 degenerate.png"
))
.write("degenerate.png", [1; 1025])
.rpc_server(&rpc_server)
Expand All @@ -336,7 +334,7 @@ fn regtest_has_no_content_size_limit() {
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file degenerate.png"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 degenerate.png"
))
.write("degenerate.png", [1; 1025])
.rpc_server(&rpc_server)
Expand All @@ -349,7 +347,7 @@ fn inscribe_does_not_use_inscribed_sats_as_cardinal_utxos() {
let rpc_server = test_bitcoincore_rpc::spawn_with(Network::Regtest, "ord");
let txid = rpc_server.mine_blocks_with_subsidy(1, 800)[0].txdata[0].txid();
CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file degenerate.png"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 degenerate.png"
))
.write("degenerate.png", [1; 100])
.rpc_server(&rpc_server)
Expand All @@ -359,7 +357,7 @@ fn inscribe_does_not_use_inscribed_sats_as_cardinal_utxos() {
let txid = rpc_server.mine_blocks_with_subsidy(1, 100)[0].txdata[0].txid();

CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file degenerate.png"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 degenerate.png"
))
.rpc_server(&rpc_server)
.write("degenerate.png", [1; 100])
Expand All @@ -373,7 +371,7 @@ fn send_does_not_use_inscribed_sats_as_cardinal_utxos() {
let rpc_server = test_bitcoincore_rpc::spawn_with(Network::Regtest, "ord");
let txid = rpc_server.mine_blocks_with_subsidy(1, 800)[0].txdata[0].txid();
CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file degenerate.png"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 degenerate.png"
))
.write("degenerate.png", [1; 100])
.rpc_server(&rpc_server)
Expand All @@ -397,7 +395,7 @@ fn refuse_to_reinscribe_sats() {

let txid = rpc_server.mine_blocks_with_subsidy(1, 800)[0].txdata[0].txid();
let stdout = CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file degenerate.png"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 degenerate.png"
))
.write("degenerate.png", [1; 100])
.rpc_server(&rpc_server)
Expand All @@ -409,7 +407,7 @@ fn refuse_to_reinscribe_sats() {
rpc_server.mine_blocks_with_subsidy(1, 100)[0].txdata[0].txid();

CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {first_inscription_id}:0:0 --file hello.txt"
"--chain regtest wallet inscribe --satpoint {first_inscription_id}:0:0 hello.txt"
))
.write("hello.txt", "HELLOWORLD")
.rpc_server(&rpc_server)
Expand All @@ -426,7 +424,7 @@ fn do_not_accidentally_send_an_inscription() {

let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();
let stdout = CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file degenerate.png"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 degenerate.png"
))
.write("degenerate.png", [1; 100])
.rpc_server(&rpc_server)
Expand Down Expand Up @@ -459,7 +457,7 @@ fn refuse_to_inscribe_already_inscribed_utxo() {

let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();
let stdout = CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file degenerate.png"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 degenerate.png"
))
.write("degenerate.png", [1; 100])
.rpc_server(&rpc_server)
Expand All @@ -476,7 +474,7 @@ fn refuse_to_inscribe_already_inscribed_utxo() {
};

CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {inscription_utxo}:55555 --file hello.txt"
"--chain regtest wallet inscribe --satpoint {inscription_utxo}:55555 hello.txt"
))
.write("hello.txt", "HELLOWORLD")
.rpc_server(&rpc_server)
Expand All @@ -493,7 +491,7 @@ fn inscriptions_cannot_be_sent_by_satpoint() {
let txid = rpc_server.mine_blocks(1)[0].txdata[0].txid();

let stdout = CommandBuilder::new(format!(
"--chain regtest wallet inscribe --satpoint {txid}:0:0 --file hello.txt"
"--chain regtest wallet inscribe --satpoint {txid}:0:0 hello.txt"
))
.write("hello.txt", "HELLOWORLD")
.rpc_server(&rpc_server)
Expand Down Expand Up @@ -547,7 +545,7 @@ fn inscriptions() {

let inscription_id = reveal_txid_from_inscribe_stdout(
&CommandBuilder::new(format!(
"--chain signet wallet inscribe --satpoint {txid}:0:0 --file hello.txt"
"--chain signet wallet inscribe --satpoint {txid}:0:0 hello.txt"
))
.write("hello.txt", "HELLOWORLD")
.rpc_server(&rpc_server)
Expand Down Expand Up @@ -595,7 +593,7 @@ fn inscribe_with_optional_satpoint_arg() {
let rpc_server = test_bitcoincore_rpc::spawn_with(Network::Regtest, "ord");
rpc_server.mine_blocks(1);

let stdout = CommandBuilder::new("--chain regtest wallet inscribe --file hello.txt")
let stdout = CommandBuilder::new("--chain regtest wallet inscribe hello.txt")
.write("hello.txt", "HELLOWORLD")
.rpc_server(&rpc_server)
.stdout_regex("commit\t[[:xdigit:]]{64}\nreveal\t[[:xdigit:]]{64}\n")
Expand Down Expand Up @@ -630,7 +628,7 @@ fn transactions() {
let rpc_server = test_bitcoincore_rpc::spawn_with(Network::Signet, "ord");
rpc_server.mine_blocks(1);

let stdout = CommandBuilder::new("--chain signet wallet inscribe --file degenerate.png")
let stdout = CommandBuilder::new("--chain signet wallet inscribe degenerate.png")
.write("degenerate.png", [1; 520])
.rpc_server(&rpc_server)
.stdout_regex("commit\t[[:xdigit:]]{64}\nreveal\t[[:xdigit:]]{64}\n")
Expand Down Expand Up @@ -668,12 +666,11 @@ fn inscribe_gif() {
let rpc_server = test_bitcoincore_rpc::spawn_with(Network::Regtest, "ord");
rpc_server.mine_blocks(1)[0].txdata[0].txid();

let stdout =
CommandBuilder::new("--chain regtest --index-sats wallet inscribe --file dolphin.gif")
.write("dolphin.gif", [1; 520])
.rpc_server(&rpc_server)
.stdout_regex("commit\t[[:xdigit:]]{64}\nreveal\t[[:xdigit:]]{64}\n")
.run();
let stdout = CommandBuilder::new("--chain regtest --index-sats wallet inscribe dolphin.gif")
casey marked this conversation as resolved.
Show resolved Hide resolved
.write("dolphin.gif", [1; 520])
.rpc_server(&rpc_server)
.stdout_regex("commit\t[[:xdigit:]]{64}\nreveal\t[[:xdigit:]]{64}\n")
.run();

let txid = reveal_txid_from_inscribe_stdout(&stdout);

Expand Down