From 3ae6e9e46956416164c4540881a3acb81aa0c672 Mon Sep 17 00:00:00 2001 From: Adam Soltys Date: Sat, 12 Sep 2020 15:47:00 -0700 Subject: support rbf --- lib/buildtx.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/buildtx.js') diff --git a/lib/buildtx.js b/lib/buildtx.js index ef24ea19..0f63f641 100644 --- a/lib/buildtx.js +++ b/lib/buildtx.js @@ -8,7 +8,7 @@ const network = prod ? bitcoin.networks["bitcoin"] : bitcoin.networks["regtest"]; -module.exports = async ({ address, amount, feeRate, user }) => { +module.exports = async ({ address, amount, feeRate, replaceable, user }) => { if (!feeRate) feeRate = (await bc.estimateSmartFee(6)).feerate * SATS; feeRate = Math.round(feeRate / 1000); @@ -69,6 +69,8 @@ module.exports = async ({ address, amount, feeRate, user }) => { }); } + if (replaceable) psbt.setInputSequence(0, 0xffffffff - 2); + feeRate = Math.round(feeRate * 1000); psbt = psbt.toBase64(); -- cgit v1.2.3