An ecash wallet class. Manage keys, build and broadcast txs. Includes support for tokens and agora.
npm install ecash-walletA production-ready wallet class for building and broadcasting eCash (XEC) txs
Install with npm (when published).
npm i ecash-wallet
Import. Create your Wallet and use methods.
``
import { Wallet } from "ecash-wallet";
const mnemonic = 'morning average minor stable parrot refuse credit exercise february mirror just begin',
const wallet = Wallet.fromMnemonic(mnemonic, chronik);
`
See tests for detailed methods.
ecash-wallet is engineered to be a drop-in wallet lib for any ecash application that needs wallet functionality. The first milestone demonstrating minimal fulfillment of this requirement will be the integration of ecash-wallet into Cashtab.
- XEC actions
[x] Send XEC to one recipient
[x] Send XEC to many recipients
- GENESIS, MINT, SEND, and BURN for all token types
[x] SLP_TOKEN_TYPE_FUNGIBLE
[x] ALP_TOKEN_TYPE_STANDARD
[x] SLP_TOKEN_TYPE_MINT_VAULT SEND and BURN actions
[x] SLP_TOKEN_TYPE_NFT1_GROUP
[x] SLP_TOKEN_TYPE_NFT1_CHILD (Mint NFTs)
[x] DataAction for ALP_TOKEN_TYPE_STANDARD txs
[X] BURN txs for arbitrary amounts using BURN method (intentional burn, not SEND)
[X] One-step mints for SLP NFTs
- Agora actions (PARTIAL and ONESHOT)
[] SLP (requires "chained" txs)
[] ALP
[x] Support for chained XEC txs, i.e. handling an Action that requires more than one tx due to the 100,000 byte tx size restriction
[x] Support for chained token txs, i.e. handling an Action that requires more than one tx due to token protocol per-tx output limits
[] HD wallets
[] Fine-grained utxo control, avalanche proofs
[] SLP_TOKEN_TYPE_MINT_VAULT GENESIS and MINT actions
- 0.0.0 Init with constructor and sync method D17773getFuelUtxos
- 0.0.1 Add utxo getter methods and getSpendableCoinbaseUtxos D17779
D17822 Add support for building and broadcasting txs, including ALP and SLP token txs. Update methods and syntax. Add preliminary support for Postage protocol.
D18384 Add fromMnemonic constructor, make Wallet a normal export (not uniquely a default export), call broadcastTx using hex rawTx to facilitate testing with mock-chronik-client (practical improvements from implementing ecash-wallet in cashtab-faucet)main
D18390 Patch the entry in package.json to point to dist/index.js
D18391 Patch README
D18398 Accept addresses in the transaction ouputs
D18548 Support GENESIS, SEND, and BURN for SLP_TOKEN_TYPE_MINT_VAULT
D18551 Support GENESIS, SEND, MINT, and BURN for SLP_TOKEN_TYPE_NFT1_GROUP
D18558 Support GENESIS, SEND, and BURN for SLP_TOKEN_TYPE_NFT1_CHILD
D18585 Support DataAction for ALP token sends
- Support intentional SLP burns for arbitrary amounts with a chained tx.
- Support automatic updating of determined wallet utxo set on tx build() (unless user opts out, e.g. for running tests) (NB does not apply to PostageTx)
- _BREAKING CHANGE_ the .broadcast() method no longer throws, returns a success key with more information
- Patch issue where SLP burns are not invalidated for including specified outputs
- Type errors uncovered when using ecash-wallet as a dep in ecash-agora
- Support chained txs for minting SLP NFTs without requiring a "fan-out" tx
- Patch type issue in returning SelectUtxosResult
- Export the BuiltAction class to support the user of Wallet in the ecash-agora AgoraOffer take method
- Return sats selection strategy used to select utxos with SelectUtxosResult
- Update the PostageTx class to support client/server postage interactions
- Support chained txs to handle XEC-only Actions that would exceed MAX_TX_SERSIZE if built in a single tx
- Prevent addFuelAndSign from adding unnecessary postage
- Automatically remove consumed postage utxos from the postage wallet in addFuelAndSign method
- Tolerate token outputs without the isMintBaton key, but always classify such inputs as if they were isMintBaton: false
- Publish to catch updated chronik-client dep
- Publish to catch updated chronik-client dep
- Publish to catch updated chronik-client dep
- Add stub methods for HD support (not a functional wallet, but could be used to derive different accounts)
- Add methods for getting receive and change addresses for HD wallets
- Add sync() support for the HD walletWalletUtxo
- Introduce new type with included address key, which will help match utxos with keypairs for HD transaction signing (breaking change)
- Add balanceSats as wallet property that updates on sync()
- Support for msg signing and txs from HD wallets
- Similar to non-HD, we also "auto-update" the wallet's utxo set after txs are built
- For a consistent API, we introduce methods that return different addresses/scripts depending on whether or not the wallet is HD
- For ALP burns, if we do not have an exact qty utxo, we infer a SEND action for change
- Introduce action preprocessing and typed error, ExactAtomsNotFoundError, to support this inferrence
- Support for chained token txs
- Add maxSendSats method for determining how many sats we can send to leave no balance remaining in the wallet
- If broadcasting a tx fails due to bad-txns-inputs-missingorspent or txn-mempool-conflict, resync the utxo set and try again
- Update method name updateBalance instead of updateBalances
- Add addReceivedTx method to support updating the utxo set and balance of a wallet with an incoming tx, including processing inputs to remove spent UTXOs
- Make addReceivedTx robust against txs with non-standard address types
- If broadcasting a tx fails due to finalized-tx-conflict, resync the utxo set and try again
- Add a WalletAction.inspect() method that can't be broadcasted and won't update the utxos. This can be used to inspect the tx and compute the fees without impacting the wallet.
- Add a Wallet.isWalletAddress() method to check if an address belongs to the wallet.Wallet.getTxAmounts()
- Add a to get all the balance changes introduced by a transaction from the wallet history.
- Add a new class WatchOnlyWallet to support watch only wallets (both HD and single-address)
- Add support for wallets using a custom prefix
- Add support for building token postage aka "swap" txs (partially signed txs with token outputs that require added token inputs)
- Changes the API as satsStrategy is no longer its own param, now part of SelectUtxosConfig`