Open adrianbarwicki opened 5 years ago
I like having a simple way to send BCH straight from bitbox-sdk, think it would be really valuable. But I think maybe rather than having to create a new wallet, it might integrate better with bitbox to do one of the following:
send
function to bitbox:
bitbox.send(from: ECPair, receivers: ({ to: string, value: number } | { opReturn: string[] })[])
// Possible override for single send: bitbox.send(from: ECPair, to: string, value: number)
2. Extend ECPair with a `send` function:
```ts
const keypair: ECPair = ...
keypair.send(receivers: ({ to: string, value: number } | { opReturn: string[] })[])
// Again, possible override for single send:
const keypair: ECPair = ...
keypair.send(to: string, value: number)
To facilitate the simple creation of a wallet, we could instead add a simple creation of an ECPair, similar to what you're proposing.
const keypair: ECPair = ECPair.fromMnemonic("<mnemonic here>", {
HdPath: "m/44'/0'/0'/1'";
});
That way we don't need to add any new classes such as BCHSingleAccountWalletInstance
, instead using the primitives that are already in BITBOX, and extending their functionality.
These are my thoughts, what do you think @adrianbarwicki @cgcardona?
These convenience methods are largely what I was trying to accomplish by creating bch-cli-wallet: https://github.com/christroutner/bch-cli-wallet
This library contains the next level of abstraction. BITBOX is a library for doing low-level tasks like generating mnemonics, EC key pairs, signing transactions, etc. bch-cli-wallet has high-level functions such as create-wallet, send bch, get address, update-balance etc.
I sort of agree. But I think right now bch-cli-wallet functions more for people to look at the code on how to implement these kinds of things, and then implement similar code in their app (like we did with simple-bitcoin-wallet). Rather than people actually npm installing bch-cli-wallet and using it inside applications. If we want to keep bitbox as low-level as it is currently, it might be valuable to position bch-cli-wallet (or another project) as the logical layer on top of bitbox that can be readily used inside other applications (without requiring any situational code changes).
Agreed. My thoughts have been going along the same line.
I'd like to extract a lot of the existing code in bch-cli-wallet as a stand-alone library, then refactor bch-cli-wallet to use that library. bch-cli-wallet is getting so complex that it's getting unwieldy trying to be both a library and a CLI app.
Convenience methods would make the library much easier to use and become more accessible to new developers.
At Honest, we maintain our own library wrapping BITBOX and extending it with some convenience methods. Was Bitbox to incorporate these, we could completely deprecate the
simple-bitcoin-wallet
wrapper and use Bitbox directly.Proposal
In detail, it would be great to have the following methods:
Example:
Example:
Mark the support for OP_RETURNS: