Skip to content

Commit 74d771a

Browse files
author
Danny Diekroeger
committed
BG-10752 support BSV
1 parent e6d38e7 commit 74d771a

File tree

4 files changed

+16
-1
lines changed

4 files changed

+16
-1
lines changed

app/sign.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ const utxoNetworks = {
1313
btc: utxoLib.networks.bitcoin,
1414
ltc: utxoLib.networks.litecoin,
1515
bch: utxoLib.networks.bitcoincash,
16+
bsv: utxoLib.networks.bitcoinsv,
1617
zec: utxoLib.networks.zcash,
1718
dash: utxoLib.networks.dash,
1819
tltc: utxoLib.networks.litecoin,
1920
tbtc: utxoLib.networks.testnet,
2021
tbch: utxoLib.networks.bitcoincashTestnet,
22+
tbsv: utxoLib.networks.bitcoinsvTestnet,
2123
tzec: utxoLib.networks.zcashTest,
2224
tdash: utxoLib.networks.dashTest,
2325
};
@@ -27,6 +29,7 @@ const coinDecimals = {
2729
eth: 18,
2830
xrp: 6,
2931
bch: 8,
32+
bsv: 8,
3033
ltc: 8,
3134
zec: 8,
3235
dash: 8,
@@ -37,10 +40,12 @@ const coinDecimals = {
3740
tltc: 8,
3841
txlm: 7,
3942
tbch: 8,
43+
tbsv: 8,
4044
tzec: 8,
4145
tdash: 8,
4246
};
4347

48+
const BCH_COINS = ['bch', 'tbch', 'bsv', 'tbsv'];
4449
const TEN = new BN(10);
4550

4651
const confirmRecovery = function(backupKey, outputs, customMessage, skipConfirm) {
@@ -130,7 +135,7 @@ const handleSignUtxo = function(recoveryRequest, key, skipConfirm) {
130135
console.log(`Signing input ${ i + 1 } of ${ recoveryRequest.inputs.length } with ${ derivedHDNode.neutered().toBase58() } (${ input.chainPath })`);
131136

132137
// Handle BCH
133-
if (recoveryRequest.coin === 'bch' || recoveryRequest.coin === 'tbch') {
138+
if (BCH_COINS.includes(recoveryRequest.coin)) {
134139
const redeemScript = new Buffer(input.redeemScript, 'hex');
135140
txBuilder.sign(i, derivedHDNode.keyPair, redeemScript, utxoLib.Transaction.SIGHASH_BITCOINCASHBIP143 | utxoLib.Transaction.SIGHASH_ALL, input.amount);
136141
return; // in a Lodash forEach loop, 'return' operates like 'continue' does in a regular javascript loop. It finishes this iteration and moves to the next iteration

config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ module.exports = {
1212
tltc: 'xpub',
1313
bch: 'xpub',
1414
tbch: 'xpub',
15+
bsv: 'xpub',
16+
tbsv: 'xpub',
1517
zec: 'xpub',
1618
tzec: 'xpub',
1719
xrp: 'xpub',

test/sign.js

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/transactions/tbsv.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"xpub":"xpub661MyMwAqRbcFV9SLF3EQccZbhbUbA6tb4R18Dq8H5jwBAZrHvDA2uftPqzcC5AqHW86qvZsVRH5z1PBLnNDUSWNKEvKgBHmeWmnbG2ahQV","backupKey":"xpub661MyMwAqRbcFV9SLF3EQccZbhbUbA6tb4R18Dq8H5jwBAZrHvDA2uftPqzcC5AqHW86qvZsVRH5z1PBLnNDUSWNKEvKgBHmeWmnbG2ahQV","userEmail":"[email protected]","transactionHex":"0100000001d16772a94f0d82db7803fc73ff445feb6af8c3e079ae20017f9b74eafe8722de01000000b7000000483045022100871fdfc6122a93736fa83a455303965f0659d0c6ec2cf044c56b1b1ed44c3ac302204abb5243932895f0acaee42fd462f142bef5ece8bff733e6ef580ac865ed7be5414c6952210398f189c1661704865526b9950f1b70632a6a4e8bc9cf2d4df3b98fd59a3716c021021ca598baf3e740f1a017e086f9edff885ea491847ac2413e8250d39c1e3ccd8d21039070d667c42d9eabde8d79fd00eec3a031afca352cd3a002f4369bdc7b94953253aeffffffff0108ef5e010000000017a914b72b1311fada7342116342284880f61464f490e38700000000","tx":"0100000001d16772a94f0d82db7803fc73ff445feb6af8c3e079ae20017f9b74eafe8722de01000000b7000000483045022100871fdfc6122a93736fa83a455303965f0659d0c6ec2cf044c56b1b1ed44c3ac302204abb5243932895f0acaee42fd462f142bef5ece8bff733e6ef580ac865ed7be5414c6952210398f189c1661704865526b9950f1b70632a6a4e8bc9cf2d4df3b98fd59a3716c021021ca598baf3e740f1a017e086f9edff885ea491847ac2413e8250d39c1e3ccd8d21039070d667c42d9eabde8d79fd00eec3a031afca352cd3a002f4369bdc7b94953253aeffffffff0108ef5e010000000017a914b72b1311fada7342116342284880f61464f490e38700000000","id":"405661c89a104fc914d06f9d10c6c0f662788a98b00cff85e9943b8c36cebbec","txid":"405661c89a104fc914d06f9d10c6c0f662788a98b00cff85e9943b8c36cebbec","inputs":[{"chainPath":"0/0/1/1","path":"0/0/1/1","redeemScript":"52210398f189c1661704865526b9950f1b70632a6a4e8bc9cf2d4df3b98fd59a3716c021021ca598baf3e740f1a017e086f9edff885ea491847ac2413e8250d39c1e3ccd8d21039070d667c42d9eabde8d79fd00eec3a031afca352cd3a002f4369bdc7b94953253ae","amount":22999252}],"coin":"tbsv","custom":{"message":"Recovery initiated by BitGo on behalf of user"}}

0 commit comments

Comments
 (0)