sendover

Tools for creating and paying invoices privately on Bitcoin SV

Usage no npm install needed!

<script type="module">
  import sendover from 'https://cdn.skypack.dev/sendover';
</script>

README

sendover

Tools for creating and paying invoices privately on Bitcoin SV

Example Usage

const sendover = require('sendover')

// The merchant generates a keypair.
// They put the public key on their website, and keep the private key secret.
const merchantKeypair = sendover.generateKeypair()

// The customer also generates a keypair.
const customerKeypair = sendover.generateKeypair()

// The customer and the merchant agree on an invoice number.
// The customer knows the invoice number.
const purchaseInvoiceNumber = '341-9945319'

// The customer can now generate a Bitcoin addres for the payment.
// After generating the address, the customer sends the payment.
const paymentAddress = sendover.getPaymentAddress({
  senderPrivateKey: customerKeypair.privateKey,
  recipientPublicKey: merchantKeypair.publicKey,
  invoiceNumber: purchaseInvoiceNumber
})

// After making the payment, the customer sends a few things to the merchant.
// - The Bitcoin transaction that contains the payment
// - The invoice number they have agreed upon
// - The customer's public key
// - Any SPV proofs needed for the merchant to validate and accept the transaction
const dataSentToMerchant = {
  customerPublicKey: customerKeypair.publicKey,
  paymentTransaction: '...', // transaction that pays money to the address
  invoiceNumber: purchaseInvoiceNumber,
  transactionSPVProofs: ['...'] // Any needed SPV proofs
}

// The merchant can now calculate the private key that unlocks the money.
const privateKey = sendover.getPaymentPrivateKey({
  senderPublicKey: dataSentToMerchant.customerPublicKey,
  recipientPrivateKey: merchantKeypair.privateKey,
  invoiceNumber: dataSentToMerchant.invoiceNumber
})

API

Table of Contents

generateKeypair

Generates a public/private keypair for the sending and receiving of invoices.

Returns Object The generated keypair, with privateKey and publicKey properties.

getPaymentAddress

Returns a payment address for use by the sender, given the recipient's public key, the sender's private key and the invoice number.

Parameters

  • $0 Object

    • $0.senderPrivateKey
    • $0.recipientPublicKey
    • $0.invoiceNumber

Returns String The base58 Bitcoin address where the payment is to be sent.

getPaymentPrivateKey

Returns a private key for use by the recipient, given the sender's public key, the recipient's private key and the invoice number.

Parameters

  • $0 Object

    • $0.recipientPrivateKey
    • $0.senderPublicKey
    • $0.invoiceNumber

Returns String The base58 Bitcoin private key that can unlock the money.

Credits

Credit is given to the people who have worked on making these ideas into reality. In particular, we thank Xiaohui Liu for creating the first known implementation of private addresses using this scheme, and Dr. Craig Wright for first describing it.

License

The license for the code in this repository is the Open BSV License.