0.38.8 • Published 3 years ago

@moneybutton/purse v0.38.8

Weekly downloads
-
License
Open-BSV
Repository
github
Last release
3 years ago

@moneybutton/purse

Description

This is a simple module to fund arbitrary bitcoin transactions using Invisible Money Button.

How it works.

const imb = new moneyButton.imb({ clientIdentifier: '<your_client_identifier>' })
const paymailClient = new PaymailClient()
const purse = new MBPurse(imb, bsv, paymailClient)

const tx = new bsv.Transaction()
tx.to(someAddress, 600)
tx.to(someAddress, 900)

const fundedRawTx = purse.pay(tx.uncheckedSerialize())
console.log(fundedRawTx)

If the transaction to fund contains input is necesary to send a second argument with a list with metadata for the inputs. In particular the amount of satoshis included in the output spent by every input.

const imb = new moneyButton.imb({ clientIdentifier: '<your_client_identifier>' })
const paymailClient = new PaymailClient()
const purse = new MBPurse(imb, bsv, paymailClient)

const tx = new bsv.Transaction()
tx.from(new bsv.Transaction.UnspentOutput, {
  txid: 'sometxid',
  vout: 0,
  satoshis: 650
})
tx.from(new bsv.Transaction.UnspentOutput, {
  txid: 'sometxid',
  vout: 0,
  satoshis: 820
})
tx.to(someAddress, 2000)
tx.to(someAddress, 3000)

const fundedRawTx = purse.pay(tx.uncheckedSerialize(), [{ satoshis: 650 }, { satoshis: 820 }]) // the list has a 1-1 match with the inputs.
console.log(fundedRawTx)
0.38.8

3 years ago

0.38.7

3 years ago

0.38.6

3 years ago

0.38.5

4 years ago

0.38.4

4 years ago