bitshares / bitsharesjs

JavaScript tools for BitShares Encryption and Serialization
https://bitsharesjs.bitshares.org/
MIT License
96 stars 148 forks source link

Allow to load a raw transaction into a Transaction builder #48

Closed xeroc closed 5 years ago

xeroc commented 5 years ago

I want to be able to load a raw transaction into a transaction builder process (the tx is constructed elsewhere).

What needs to be done:


function load_tx(tx) {
   var txbuilder = bitshares_js.TransactionBuilder;
   var ops = bitshares_js.serializer.ops

   var tr = new txbuilder()
   // I need to do this manually, this is usually done in `finalize` but then it replaces the expiration, and ref_block_* parameters, which i want to pass over manually!!!
   tr.tr_buffer = ops.transaction.toBuffer(tx);

   // load stuff outside operations
   tr.expiration = tx.expiration;
   tr.ref_block_num = tx.ref_block_num;
   tr.ref_block_prefix = tx.ref_block_prefix;

   //load operations
   for (var i=0; i< tx.operations.length; ++i) {
    tr.add_operation(tx.operations[i]);
   }

   return tx
}
sschiessl-bcp commented 5 years ago

Closed by https://github.com/bitshares/bitsharesjs/pull/49