Skip to content

Commit 3d76a8f

Browse files
committed
TxBuilder: max output size + multiple change address support
Users with many NFTs could run into problems creating certain txs that returned many of them as a change output as it would surpass the maximum output size limit in the ledger. The TxBuilder now takes this limit into account and errors if it is passed, and during the change output creation will attempt to spread out the NFTs over multiple outputs to not surpass the ledger limit. This is done as a greedy selection for now as the limit is currently 4kb or so and each asset is at most 64 bytes each so this should suffice.
1 parent 0825673 commit 3d76a8f

File tree

3 files changed

+303
-65
lines changed

3 files changed

+303
-65
lines changed

rust/src/lib.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ impl TransactionInput {
385385
#[derive(Clone, Debug)]
386386
pub struct TransactionOutput {
387387
address: Address,
388-
amount: Value,
388+
pub (crate) amount: Value,
389389
data_hash: Option<DataHash>,
390390
}
391391

@@ -2461,7 +2461,9 @@ pub type PolicyIDs = ScriptHashes;
24612461

24622462
#[wasm_bindgen]
24632463
#[derive(Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
2464-
pub struct Assets(std::collections::BTreeMap<AssetName, BigNum>);
2464+
pub struct Assets(pub (crate) std::collections::BTreeMap<AssetName, BigNum>);
2465+
2466+
to_from_bytes!(Assets);
24652467

24662468
#[wasm_bindgen]
24672469
impl Assets {
@@ -2488,7 +2490,7 @@ impl Assets {
24882490

24892491
#[wasm_bindgen]
24902492
#[derive(Clone, Debug, Eq, Ord, PartialEq)]
2491-
pub struct MultiAsset(std::collections::BTreeMap<PolicyID, Assets>);
2493+
pub struct MultiAsset(pub (crate) std::collections::BTreeMap<PolicyID, Assets>);
24922494

24932495
to_from_bytes!(MultiAsset);
24942496

0 commit comments

Comments
 (0)