Skip to content

refactor payjoin-cli App::bitcoind #478

@nothingmuch

Description

@nothingmuch

The bitcoind method of payjoin-cli's App trait uses the values in AppConfig and returns a bitcoin rpc client handle, which the other trait methods use.

This issue is mainly to document some WIP that is currently on hold as per call yesterday, so that we don't forget it.

This is suboptimal:

  1. due to the reliance on AppConfig, which once payjoin-cli has additive features would actually be two distinct types (but for this purpose duck typing equivalent), no default implementation is given in the trait which results in duplication
  2. the RPC api is low level for this purpose, which makes it hard to read and compare the v1 and v2 implementations of the App trait

A new struct that wraps the RPC API, and provides methods tailored for payjoin (e.g. all of the details to generate an address, handle the psbt workflow and serialization) would improve (2).

I don't yet have a clean solution for (1). Extracting the bitcoin specific config data from AppConfig into a shared BitcoinConfig type for example seems like it'd be the cleanest approach to reduce that duplication but this would either break the serialization compatibility or introduce a bunch of boilerplate for backwards compatibility. I suspect backwards incompatibility is justified in this case, since the main purpose of payjoin cli is as a reference implementation, i.e. it should prioritize readability.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions