Rebuilding Transaction
Rebuilding a transaction starts from obtaining the TxBuilderBody
, which can be obtained by either of the methods from TxParser
:
get_builder_body
- get the entireTxBuilderBody
of the current transaction parsedget_builder_body_without_change
- get theTxBuilderBody
without the last outputThis is the recommended method for rebuilding the transaction since the
complete
method ofTxBuilder
would re-calculate the change as per the manipulation. Thus, the rebuilt transaction will be in an expected shape without one extra output.
Full Example
// let body = tx_parser.get_builder_body();
let body = tx_parser.get_builder_body_without_change();
let mut new_tx_builder = TxBuilder::new_core();
// manipulation of the `tx_builder_body` as needed here
new_tx_builder.tx_builder_body = body.clone();
new_tx_builder
// extra tx building methods as needed here
.complete_sync(None)
.unwrap();
Last updated