I'd like to generate a double spend transaction and increase the gas fees over the previous, unconfirmed transaction that has been stuck for a week. I know there's other answers regarding double spend but I'm looking for more of a technical answer specific to my thought process and sample code.

I understand the general premise is to recreate the originating transaction in its entirety. I've started by utilizing bitcore-lib to perform a getRawTransaction of my currently stuck transaction. From here, I'm iterating over the vin and performing a getRawTransaction of the vin's txid to retrieve the parent. I'm then parsing the parent, iterating over each vout and looking for vout.n to match the previous vin.vout. Once I find a match, I'm generating a utxo which effectively looks like this:

const utxo = {
    address: output.scriptPubKey.addresses[0],
    txId: vin.txid,
    outputIndex: vin.vout,
    script: output.scriptPubKey,
    satoshis: output.value

I then use these utxos to generate and sign the transaction as follows (sorry for lack of full class, but the actual process of signing transactions is fully functional):

const transaction = new Bitcore.Transaction();

targets.forEach((target) => {
    transaction.to(target.address, this.amountToSatoshis(target.amount));

So my questions are...

  1. Is my thought process correct in how I could go about regenerating the original transaction for submission by bitcore?
  2. Is there an easier way to regenerate the transaction and increase the fees than how I'm trying to do it?
  3. When attempting to replicate/duplicate the previous utxos, would I want to also provide the sequence number in the utxo?
  4. Will this even work or will I even be able to submit this transaction to my same core node?
  5. If it won't work, would it work if I ran -zapwallettxes on the core node first?
  • You are probably better off just doing a Child Pays For Parent transaction, assuming there was a change output and/or you are the recipient.
    – m1xolyd1an
    Apr 22, 2021 at 2:10
  • In this scenario, I am the sender wishing to increase the gas fees of my sent transaction @m1xolyd1an. It's currently being sent to an exchange address I don't control. Apr 23, 2021 at 12:30


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.