From beed13eaff9bbbf1df9d494f9e846a4c4b0d8c17 Mon Sep 17 00:00:00 2001 From: Gaurav Sharma Date: Sun, 10 Oct 2021 16:08:07 +0530 Subject: [PATCH] Updated pool and util to support p2sh-segwit type of address --- lib/pool.js | 4 ++-- lib/util.js | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/pool.js b/lib/pool.js index e5f52c9d7..b9a1d7097 100644 --- a/lib/pool.js +++ b/lib/pool.js @@ -421,9 +421,9 @@ var pool = module.exports = function pool(options, authorizeFn){ options.poolAddressScript = (function(){ switch(options.coin.reward){ case 'POS': - return util.pubkeyToScript(rpcResults.validateaddress.pubkey); + return util.pubkeyToScript(rpcResults.validateaddress.pubkey, rpcResults.validateaddress.isscript); case 'POW': - return util.addressToScript(rpcResults.validateaddress.address); + return util.addressToScript(rpcResults.validateaddress.address, rpcResults.validateaddress.isscript); } })(); diff --git a/lib/util.js b/lib/util.js index 394d05997..23e2d85a7 100644 --- a/lib/util.js +++ b/lib/util.js @@ -261,7 +261,7 @@ exports.miningKeyToScript = function(key){ /* For POW coins - used to format wallet address for use in generation transaction's output */ -exports.addressToScript = function(addr){ +exports.addressToScript = function(addr, p2shSupportedAddr = false){ var decoded = base58.decode(addr); @@ -277,6 +277,9 @@ exports.addressToScript = function(addr){ var pubkey = decoded.slice(1,-4); + if(p2shSupportedAddr) + return Buffer.concat([new Buffer([0xa9, 0x14]), pubkey, new Buffer([0x87])]); + return Buffer.concat([new Buffer([0x76, 0xa9, 0x14]), pubkey, new Buffer([0x88, 0xac])]); };