@kevinejohn/atfinder v2.0.1
AtFinder
Paymail Client
The code is hosted on GitHub and the package is available through NPM.
Installation
npm i atfinderExample Usage
const atfinder = require('atfinder')
const paymail = 'ty@tyweb.us'
// 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
- paymailString the handle of the target
- configObject? optional configuration options (optional, default- {})- config.dohServerString DNS-over-HTTPS resolver (optional, default- https://dns.google.com/resolve)
 
- Throws any appropriate errors if the request did not succeed
Returns Promise[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) response from the Paymail server
getNameAndPhotoURL
Use this function to get the name nad avatar photo URL of a handle.
Parameters
- paymailString the handle of the target
- configObject? optional configuration options- config.dohServerString DNS-over-HTTPS resolver (optional, default- https://dns.google.com/resolve)
 
- Throws any appropriate errors if the request did not succeed
Returns Promise[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) response from the Paymail server
requestOutputsForP2PTransaction
Use this function to get a payment invoice for a P2P or SPV transaction
Parameters
- paymailString the handle of the target
- satoshisNumber the amount of satoshis to send
- configObject? optional configuration options- config.dohServerString DNS-over-HTTPS resolver (optional, default- https://dns.google.com/resolve)
 
- Throws any appropriate errors if the request did not succeed
Returns Promise[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/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
- paymailString the handle of the recipient
- envelopeObject the SPV envelope containing the transaction, which must include all specified envelope fields in addition to those listed
- configObject? optional configuration options- config.dohServerString DNS-over-HTTPS resolver (optional, default- https://dns.google.com/resolve)
 
- Throws any appropriate errors if the request did not succeed
Returns Promise[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/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
- paymailString the handle of the recipient
- referenceString the reference number provided by requestOutputsForP2PTransaction
- hexString the signed Bitcoin transaction
- metadataObject? optional information about the payment
- configObject? optional configuration options- config.dohServerString DNS-over-HTTPS resolver (optional, default- https://dns.google.com/resolve)
 
- Throws any appropriate errors if the request did not succeed
Returns Promise[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) response from the Paymail server
verifyPublicKeyForPaymail
Use this function to verify that a given identity key belongs to a handle.
Parameters
- paymailString the handle of the target
- publicKeyString the DER-encoded public key to verify
- configObject? optional configuration options- config.dohServerString DNS-over-HTTPS resolver (optional, default- https://dns.google.com/resolve)
 
- Throws any appropriate errors if the request did not succeed
Returns Promise[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) response from the Paymail server
getIdentityKeyForPaymail
Use this function to get the identity key of a handle.
Parameters
- paymailString the handle of the target
- configObject? optional configuration options- config.dohServerString DNS-over-HTTPS resolver (optional, default- https://dns.google.com/resolve)
 
- Throws any appropriate errors if the request did not succeed
Returns Promise[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/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
- paymailString the handle of the target
- authriteClientObject the initialized Authrite client to use
- configObject? optional configuration options- config.dohServerString DNS-over-HTTPS resolver (optional, default- https://dns.google.com/resolve)
 
- Throws any appropriate errors if the request did not succeed
Returns Promise[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/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
- paymailString the handle of the recipient
- bodyObject the body of the request, including- protocoland- transactionsfields
- authriteClientObject an initialized Authrite client to use
- configObject? optional configuration options- config.dohServerString DNS-over-HTTPS resolver (optional, default- https://dns.google.com/resolve)
 
- Throws any appropriate errors if the request did not succeed
Returns Promise[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object) response from the Paymail server
License
The license for the code in this repository is the Open BSV License.