atfinder v1.1.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 targetconfigObject? optional configuration options (optional, default{})config.dohServerString DNS-over-HTTPS resolver (optional, defaulthttps://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 targetconfigObject? optional configuration optionsconfig.dohServerString DNS-over-HTTPS resolver (optional, defaulthttps://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 targetsatoshisNumber the amount of satoshis to sendconfigObject? optional configuration optionsconfig.dohServerString DNS-over-HTTPS resolver (optional, defaulthttps://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 recipientenvelopeObject the SPV envelope containing the transaction, which must include all specified envelope fields in addition to those listedconfigObject? optional configuration optionsconfig.dohServerString DNS-over-HTTPS resolver (optional, defaulthttps://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 recipientreferenceString the reference number provided by requestOutputsForP2PTransactionhexString the signed Bitcoin transactionmetadataObject? optional information about the paymentconfigObject? optional configuration optionsconfig.dohServerString DNS-over-HTTPS resolver (optional, defaulthttps://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 targetpublicKeyString the DER-encoded public key to verifyconfigObject? optional configuration optionsconfig.dohServerString DNS-over-HTTPS resolver (optional, defaulthttps://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 targetconfigObject? optional configuration optionsconfig.dohServerString DNS-over-HTTPS resolver (optional, defaulthttps://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 targetauthriteClientObject the initialized Authrite client to useconfigObject? optional configuration optionsconfig.dohServerString DNS-over-HTTPS resolver (optional, defaulthttps://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 recipientbodyObject the body of the request, includingprotocolandtransactionsfieldsauthriteClientObject an initialized Authrite client to useconfigObject? optional configuration optionsconfig.dohServerString DNS-over-HTTPS resolver (optional, defaulthttps://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.