atfinder
v1.1.1
Published
Paymail Client
Downloads
110
Readme
AtFinder
Paymail Client
The code is hosted on GitHub and the package is available through NPM.
Installation
npm i atfinder
Example Usage
const atfinder = require('atfinder')
const paymail = '[email protected]'
// Get the bsvalias config file for the domain host
await atfinder.getServerConfig(paymail)
// Get the name and photo URL
await atfinder.getNameAndPhotoURL(paymail)
// Request transaction outputs
const satoshis = 1337
await atfinder.requestOutputsForP2PTransaction(paymail, satoshis)
// Submit an SPV transaction
// Note that the envelope contains the reference number
await atfinder.submitSPVTransaction(paymail, envelope)
API
Table of Contents
- getServerConfig
- getNameAndPhotoURL
- requestOutputsForP2PTransaction
- submitSPVTransaction
- deprecatedSubmitP2PTransaction
- verifyPublicKeyForPaymail
- getIdentityKeyForPaymail
- getCertifiedKey
- submitType42Payment
getServerConfig
Use this function to get the well-known bsvalias configuration object for the server that hosts a handle.
This is a low-level utility.
Parameters
paymail
String the handle of the targetconfig
Object? optional configuration options (optional, default{}
)config.dohServer
String DNS-over-HTTPS resolver (optional, defaulthttps://dns.google.com/resolve
)
- Throws any appropriate errors if the request did not succeed
Returns Promise<Object> response from the Paymail server
getNameAndPhotoURL
Use this function to get the name nad avatar photo URL of a handle.
Parameters
paymail
String the handle of the targetconfig
Object? optional configuration optionsconfig.dohServer
String DNS-over-HTTPS resolver (optional, defaulthttps://dns.google.com/resolve
)
- Throws any appropriate errors if the request did not succeed
Returns Promise<Object> response from the Paymail server
requestOutputsForP2PTransaction
Use this function to get a payment invoice for a P2P or SPV transaction
Parameters
paymail
String the handle of the targetsatoshis
Number the amount of satoshis to sendconfig
Object? optional configuration optionsconfig.dohServer
String DNS-over-HTTPS resolver (optional, defaulthttps://dns.google.com/resolve
)
- Throws any appropriate errors if the request did not succeed
Returns Promise<Object> response from the Paymail server
submitSPVTransaction
Use this function to submit an SPV transaction to a Paymail server.
Note that hashwrap can be used to create SPV envelopes.
Parameters
paymail
String the handle of the recipientenvelope
Object the SPV envelope containing the transaction, which must include all specified envelope fields in addition to those listedconfig
Object? optional configuration optionsconfig.dohServer
String DNS-over-HTTPS resolver (optional, defaulthttps://dns.google.com/resolve
)
- Throws any appropriate errors if the request did not succeed
Returns Promise<Object> response from the Paymail server
deprecatedSubmitP2PTransaction
Use this function to submit a P2P transaction to a Paymail server.
As of July 2021, this is how MoneyButton and HandCash handle P2P transactions. However, it is deprecated in favor of using submitSPVTransaction instead where possible.
Note that hashwrap can be used to create SPV envelopes.
Parameters
paymail
String the handle of the recipientreference
String the reference number provided by requestOutputsForP2PTransactionhex
String the signed Bitcoin transactionmetadata
Object? optional information about the paymentconfig
Object? optional configuration optionsconfig.dohServer
String DNS-over-HTTPS resolver (optional, defaulthttps://dns.google.com/resolve
)
- Throws any appropriate errors if the request did not succeed
Returns Promise<Object> response from the Paymail server
verifyPublicKeyForPaymail
Use this function to verify that a given identity key belongs to a handle.
Parameters
paymail
String the handle of the targetpublicKey
String the DER-encoded public key to verifyconfig
Object? optional configuration optionsconfig.dohServer
String DNS-over-HTTPS resolver (optional, defaulthttps://dns.google.com/resolve
)
- Throws any appropriate errors if the request did not succeed
Returns Promise<Object> response from the Paymail server
getIdentityKeyForPaymail
Use this function to get the identity key of a handle.
Parameters
paymail
String the handle of the targetconfig
Object? optional configuration optionsconfig.dohServer
String DNS-over-HTTPS resolver (optional, defaulthttps://dns.google.com/resolve
)
- Throws any appropriate errors if the request did not succeed
Returns Promise<Object> response from the Paymail server
getCertifiedKey
Use this function to get the Authrite type-42 certified key for a Paymail handle. Requires an initialized Authrite client as a parameter.
Parameters
paymail
String the handle of the targetauthriteClient
Object the initialized Authrite client to useconfig
Object? optional configuration optionsconfig.dohServer
String DNS-over-HTTPS resolver (optional, defaulthttps://dns.google.com/resolve
)
- Throws any appropriate errors if the request did not succeed
Returns Promise<Object> response from the Paymail server
submitType42Payment
Use this function to submit a type-42 payment to a Paymail server.
Note that hashwrap can be used to create SPV envelopes.
Parameters
paymail
String the handle of the recipientbody
Object the body of the request, includingprotocol
andtransactions
fieldsauthriteClient
Object an initialized Authrite client to useconfig
Object? optional configuration optionsconfig.dohServer
String DNS-over-HTTPS resolver (optional, defaulthttps://dns.google.com/resolve
)
- Throws any appropriate errors if the request did not succeed
Returns Promise<Object> response from the Paymail server
License
The license for the code in this repository is the Open BSV License.