bitcoin core – Learn how to create a double spend to prioritize a brand new transaction over a earlier unconfirmed transaction?

0
30


I would prefer to generate a double spend transaction and improve the gasoline charges over the earlier, unconfirmed transaction that has been caught for per week. I do know there’s different solutions concerning double spend however I am in search of extra of a technical reply particular to my thought course of and pattern code.

I perceive the overall premise is to recreate the originating transaction in its entirety. I’ve began by using bitcore-lib to carry out a getRawTransaction of my at the moment caught transaction. From right here, I am iterating over the vin and performing a getRawTransaction of the vin’s txid to retrieve the mum or dad. I am then parsing the mum or dad, iterating over every vout and in search of vout.n to match the earlier vin.vout. As soon as I discover a match, I am producing a utxo which successfully seems to be like this:

const utxo = {
    handle: output.scriptPubKey.addresses[0],
    txId: vin.txid,
    outputIndex: vin.vout,
    script: output.scriptPubKey,
    satoshis: output.worth
};

I then use these utxos to generate and signal the transaction as follows (sorry for lack of full class, however the precise means of signing transactions is totally purposeful):

const transaction = new Bitcore.Transaction();

transaction.price(this.price());
transaction.from(utxos);
targets.forEach((goal) => {
    transaction.to(goal.handle, this.amountToSatoshis(goal.quantity));
});
transaction.change(handle);
transaction.signal(this.privateKey(privateKey));

So my questions are…

  1. Is my thought course of right in how I might go about regenerating the unique transaction for submission by bitcore?
  2. Is there a neater strategy to regenerate the transaction and improve the charges than how I am making an attempt to do it?
  3. When making an attempt to duplicate/duplicate the earlier utxos, would I wish to additionally present the sequence quantity within the utxo?
  4. Will this even work or will I even have the ability to submit this transaction to my identical core node?
  5. If it will not work, would it not work if I ran -zapwallettxes on the core node first?



Supply hyperlink

Leave a reply