Skip to content

Commit

Permalink
Merge pull request #4146 from BitGo/BTC-0.forkid-comment
Browse files Browse the repository at this point in the history
chore: move comment about forkId to the right place
  • Loading branch information
OttoAllmendinger authored Dec 12, 2023
2 parents 1f032c0 + 642bad0 commit 9dde240
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions modules/utxo-lib/src/bitgo/UtxoTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ export class UtxoTransaction<TNumber extends number | bigint = number> extends b
}

addForkId(hashType: number): number {
/*
``The sighash type is altered to include a 24-bit fork id in its most significant bits.''
We also use unsigned right shift operator `>>>` to cast to UInt32
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unsigned_right_shift
*/
if (hashType & UtxoTransaction.SIGHASH_FORKID) {
const forkId = isBitcoinGold(this.network) ? 79 : 0;
return (hashType | (forkId << 8)) >>> 0;
Expand Down Expand Up @@ -100,11 +105,6 @@ export class UtxoTransaction<TNumber extends number | bigint = number> extends b
const addForkId = (hashType & UtxoTransaction.SIGHASH_FORKID) > 0;

if (addForkId) {
/*
``The sighash type is altered to include a 24-bit fork id in its most significant bits.''
We also use unsigned right shift operator `>>>` to cast to UInt32
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Unsigned_right_shift
*/
if (value === undefined) {
throw new Error(`must provide value`);
}
Expand Down

0 comments on commit 9dde240

Please sign in to comment.