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();
transaction.fee(this.fee());
transaction.from(utxos);
targets.forEach((target) => {
transaction.to(target.address, this.amountToSatoshis(target.amount));
});
transaction.change(address);
transaction.sign(this.privateKey(privateKey));
So my questions are...
- Is my thought process correct in how I could go about regenerating the original transaction for submission by
bitcore
? - Is there an easier way to regenerate the transaction and increase the fees than how I'm trying to do it?
- When attempting to replicate/duplicate the previous utxos, would I want to also provide the
sequence
number in the utxo? - Will this even work or will I even be able to submit this transaction to my same core node?
- If it won't work, would it work if I ran
-zapwallettxes
on the core node first?