atfinder

1.1.1 • Public • Published

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 = '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

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 target

  • config Object? optional configuration options (optional, default {})

    • config.dohServer String DNS-over-HTTPS resolver (optional, default https://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 target

  • config Object? optional configuration options

    • config.dohServer String DNS-over-HTTPS resolver (optional, default https://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 target

  • satoshis Number the amount of satoshis to send

  • config Object? optional configuration options

    • config.dohServer String DNS-over-HTTPS resolver (optional, default https://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 recipient

  • envelope Object the SPV envelope containing the transaction, which must include all specified envelope fields in addition to those listed

    • envelope.reference String the reference number provided by requestOutputsForP2PTransaction

    • envelope.metadata Object? optional information about the payment

      • envelope.metadata.note String? a human-readable note about the payment
      • envelope.metadata.sender String? the handle of the sender
      • envelope.metadata.pubkey String? an identity key of the sender
      • envelope.metadata.signature String? a signature on the TXID from the provided identity key
  • config Object? optional configuration options

    • config.dohServer String DNS-over-HTTPS resolver (optional, default https://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 recipient

  • reference String the reference number provided by requestOutputsForP2PTransaction

  • hex String the signed Bitcoin transaction

  • metadata Object? optional information about the payment

    • metadata.note String? a human-readable note about the payment
    • metadata.sender String? the handle of the sender
    • metadata.pubkey String? an identity key of the sender
    • metadata.signature String? a signature on the TXID from the provided identity key
  • config Object? optional configuration options

    • config.dohServer String DNS-over-HTTPS resolver (optional, default https://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 target

  • publicKey String the DER-encoded public key to verify

  • config Object? optional configuration options

    • config.dohServer String DNS-over-HTTPS resolver (optional, default https://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 target

  • config Object? optional configuration options

    • config.dohServer String DNS-over-HTTPS resolver (optional, default https://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 target

  • authriteClient Object the initialized Authrite client to use

  • config Object? optional configuration options

    • config.dohServer String DNS-over-HTTPS resolver (optional, default https://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 recipient

  • body Object the body of the request, including protocol and transactions fields

  • authriteClient Object an initialized Authrite client to use

  • config Object? optional configuration options

    • config.dohServer String DNS-over-HTTPS resolver (optional, default https://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.

Readme

Keywords

Package Sidebar

Install

npm i atfinder

Weekly Downloads

27

Version

1.1.1

License

Open BSV License

Unpacked Size

25.5 kB

Total Files

12

Last publish

Collaborators

  • tonesnotes
  • braydude
  • tyeverett