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

Split #4030

Merged
merged 55 commits into from
Oct 30, 2024
Merged

Split #4030

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
7452031
Thinking about splits
casey Oct 24, 2024
5c74351
More work
casey Oct 25, 2024
9d5eca8
Finish constructing transaction
casey Oct 25, 2024
474ca14
Enhance
casey Oct 25, 2024
9aa2f40
Import fs::File
casey Oct 25, 2024
1ac5767
Enhance
casey Oct 25, 2024
1c4ad78
Adapt
casey Oct 25, 2024
6e0e16e
Start adding tests
casey Oct 25, 2024
2f3d1f5
Foo
casey Oct 25, 2024
249a94f
Enhance
casey Oct 25, 2024
84aa8b3
Adjust
casey Oct 26, 2024
b081b9a
Modify
casey Oct 26, 2024
ce0b9b6
Reform
casey Oct 26, 2024
20dfe7a
Adapt
casey Oct 26, 2024
5d57dde
Revise
casey Oct 26, 2024
0e389b1
Merge remote-tracking branch 'upstream/master' into split
casey Oct 26, 2024
5036bd7
Add some tests
casey Oct 27, 2024
9eacd36
More tests
casey Oct 27, 2024
e769dce
more tests
casey Oct 27, 2024
fa85054
Amend
casey Oct 27, 2024
f8e0e2f
Tweak
casey Oct 27, 2024
ec88bba
Enhance
casey Oct 27, 2024
97d0825
Enhance
casey Oct 27, 2024
ac07782
Enhance
casey Oct 27, 2024
ac6c0f5
Enhance
casey Oct 27, 2024
fe5c7f5
Merge remote-tracking branch 'upstream/master' into split
casey Oct 28, 2024
53f52e3
Adjust
casey Oct 28, 2024
ef3083a
Modify
casey Oct 28, 2024
1399447
Modify
casey Oct 28, 2024
d1e4b0b
Add example splitfile
casey Oct 28, 2024
68ac001
Revise
casey Oct 28, 2024
3034ca7
Revise
casey Oct 28, 2024
ade19ad
Enhance
casey Oct 28, 2024
fa4c86c
Amend
casey Oct 28, 2024
bfad72f
Amend
casey Oct 28, 2024
bd9a534
Adapt
casey Oct 28, 2024
cf0553f
Adjust
casey Oct 28, 2024
debfb36
Amend
casey Oct 28, 2024
b9e3b7d
Adjust
casey Oct 28, 2024
63c052c
Adapt
casey Oct 28, 2024
69de0b3
Reform
casey Oct 28, 2024
89c3374
Test that unknown fields are forbidden
casey Oct 28, 2024
3ec67b4
Adjust
casey Oct 28, 2024
fc29252
Adapt
casey Oct 28, 2024
cf1d0fd
Modify
casey Oct 28, 2024
47ca761
Amend
casey Oct 28, 2024
615faa1
Adjust
casey Oct 28, 2024
a41afff
Merge remote-tracking branch 'upstream/master' into split
casey Oct 28, 2024
3d3b73c
Adapt
casey Oct 28, 2024
989bf4d
Revise
casey Oct 28, 2024
448e76f
Tweak
casey Oct 28, 2024
3355fb6
Tweak
casey Oct 28, 2024
e9139cd
Amend
casey Oct 28, 2024
09d0f9b
Reform
casey Oct 28, 2024
7bf6f87
Amend
casey Oct 28, 2024
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
15 changes: 15 additions & 0 deletions splits.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# example split file

# output fields:
# address: output recipient bitcoin address
# value: output bitcoin value (optional, defaults to minimal-non dust value for `address`)
# runes: output rune value map (values respect rune divisibility)
outputs:
- address: bc1p5d7rjq7g6rdk2yhzks9smlaqtedr4dekq08ge8ztwac72sfr9rusxg3297
value: 10 sat
runes:
UNCOMMON•GOODS: 1234
GRIEF•WAGE: 5000000
- address: 3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy
runes:
HELLO•WORLD: 22.5
2 changes: 1 addition & 1 deletion src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ impl Index {
}

pub fn export(&self, filename: &String, include_addresses: bool) -> Result {
let mut writer = BufWriter::new(fs::File::create(filename)?);
let mut writer = BufWriter::new(File::create(filename)?);
let rtx = self.database.begin_read()?;

let blocks_indexed = rtx
Expand Down
1 change: 0 additions & 1 deletion src/inscriptions/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ use {
self, BROTLI_MODE_FONT as FONT, BROTLI_MODE_GENERIC as GENERIC, BROTLI_MODE_TEXT as TEXT,
},
mp4::{MediaType, Mp4Reader, TrackType},
std::{fs::File, io::BufReader},
};

#[derive(Debug, PartialEq, Copy, Clone)]
Expand Down
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ use {
consensus::{self, Decodable, Encodable},
hash_types::{BlockHash, TxMerkleNode},
hashes::Hash,
policy::MAX_STANDARD_TX_WEIGHT,
script,
transaction::Version,
Amount, Block, Network, OutPoint, Script, ScriptBuf, Sequence, Transaction, TxIn, TxOut, Txid,
Expand All @@ -52,7 +53,7 @@ use {
clap::{ArgGroup, Parser},
error::{ResultExt, SnafuError},
html_escaper::{Escape, Trusted},
http::HeaderMap,
http::{HeaderMap, StatusCode},
lazy_static::lazy_static,
ordinals::{
varint, Artifact, Charm, Edict, Epoch, Etching, Height, Pile, Rarity, Rune, RuneId, Runestone,
Expand All @@ -70,8 +71,8 @@ use {
env,
ffi::OsString,
fmt::{self, Display, Formatter},
fs,
io::{self, Cursor, Read},
fs::{self, File},
io::{self, BufReader, Cursor, Read},
mem,
net::ToSocketAddrs,
path::{Path, PathBuf},
Expand Down
4 changes: 2 additions & 2 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl Settings {
};

let config = if let Some(config_path) = config_path {
serde_yaml::from_reader(fs::File::open(&config_path).context(anyhow!(
serde_yaml::from_reader(File::open(&config_path).context(anyhow!(
"failed to open config file `{}`",
config_path.display()
))?)
Expand Down Expand Up @@ -994,7 +994,7 @@ mod tests {

#[test]
fn example_config_file_is_valid() {
let _: Settings = serde_yaml::from_reader(fs::File::open("ord.yaml").unwrap()).unwrap();
let _: Settings = serde_yaml::from_reader(File::open("ord.yaml").unwrap()).unwrap();
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl Decode {
.bitcoin_rpc_client(None)?
.get_raw_transaction(&txid, None)?
} else if let Some(file) = self.file {
Transaction::consensus_decode(&mut io::BufReader::new(fs::File::open(file)?))?
Transaction::consensus_decode(&mut io::BufReader::new(File::open(file)?))?
} else {
Transaction::consensus_decode(&mut io::BufReader::new(io::stdin()))?
};
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/env.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ rpcport={bitcoind_port}
}

serde_json::to_writer_pretty(
fs::File::create(self.directory.join("env.json"))?,
File::create(self.directory.join("env.json"))?,
&Info {
bitcoind_port,
ord_port,
Expand Down
4 changes: 4 additions & 0 deletions src/subcommand/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub mod sats;
pub mod send;
mod shared_args;
pub mod sign;
pub mod split;
pub mod transactions;

#[derive(Debug, Parser)]
Expand Down Expand Up @@ -85,6 +86,8 @@ pub(crate) enum Subcommand {
Send(send::Send),
#[command(about = "Sign message")]
Sign(sign::Sign),
#[command(about = "Split outputs")]
Split(split::Split),
#[command(about = "See wallet transactions")]
Transactions(transactions::Transactions),
}
Expand Down Expand Up @@ -131,6 +134,7 @@ impl WalletCommand {
Subcommand::Sats(sats) => sats.run(wallet),
Subcommand::Send(send) => send.run(wallet),
Subcommand::Sign(sign) => sign.run(wallet),
Subcommand::Split(split) => split.run(wallet),
Subcommand::Transactions(transactions) => transactions.run(wallet),
}
}
Expand Down
3 changes: 2 additions & 1 deletion src/subcommand/wallet/batch_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ pub(crate) struct Batch {
shared: SharedArgs,
#[arg(
long,
help = "Inscribe multiple inscriptions and rune defined in YAML <BATCH_FILE>."
help = "Inscribe multiple inscriptions and rune defined in YAML <BATCH_FILE>.",
value_name = "BATCH_FILE"
)]
pub(crate) batch: PathBuf,
}
Expand Down
3 changes: 2 additions & 1 deletion src/subcommand/wallet/burn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ impl Burn {
self.fee_rate,
)?;

let (txid, psbt, fee) = wallet.sign_transaction(unsigned_transaction, self.dry_run)?;
let (txid, psbt, fee) =
wallet.sign_and_broadcast_transaction(unsigned_transaction, self.dry_run)?;

Ok(Some(Box::new(send::Output {
txid,
Expand Down
2 changes: 1 addition & 1 deletion src/subcommand/wallet/inscribe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ impl Inscribe {
Ok(Some(cbor))
} else if let Some(path) = json {
let value: serde_json::Value =
serde_json::from_reader(fs::File::open(path)?).context("failed to parse JSON metadata")?;
serde_json::from_reader(File::open(path)?).context("failed to parse JSON metadata")?;
let mut cbor = Vec::new();
ciborium::into_writer(&value, &mut cbor)?;

Expand Down
21 changes: 11 additions & 10 deletions src/subcommand/wallet/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ impl Send {
)?,
};

let (txid, psbt, fee) = wallet.sign_transaction(unsigned_transaction, self.dry_run)?;
let (txid, psbt, fee) =
wallet.sign_and_broadcast_transaction(unsigned_transaction, self.dry_run)?;

Ok(Some(Box::new(Output {
txid,
Expand Down Expand Up @@ -213,16 +214,16 @@ impl Send {
}

inputs.push(output);
}
}

if input_rune_balances
.get(&spaced_rune.rune)
.cloned()
.unwrap_or_default()
>= amount
{
break;
if input_rune_balances
.get(&spaced_rune.rune)
.cloned()
.unwrap_or_default()
>= amount
{
break;
}
}
}
}

Expand Down
5 changes: 4 additions & 1 deletion src/subcommand/wallet/shared_args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ pub(super) struct SharedArgs {
#[arg(
long,
alias = "nolimit",
help = "Do not check that transactions are equal to or below the MAX_STANDARD_TX_WEIGHT of 400,000 weight units. Transactions over this limit are currently nonstandard and will not be relayed by bitcoind in its default configuration. Do not use this flag unless you understand the implications."
help = "Allow transactions larger than MAX_STANDARD_TX_WEIGHT of 400,000 weight units and \
OP_RETURNs greater than 83 bytes. Transactions over this limit are nonstandard and will not be \
relayed by bitcoind in its default configuration. Do not use this flag unless you understand \
the implications."
)]
pub(crate) no_limit: bool,
}
Loading
Loading