Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: payments infrastructure. #112

Open
dan-da opened this issue Oct 24, 2021 · 0 comments
Open

feat: payments infrastructure. #112

dan-da opened this issue Oct 24, 2021 · 0 comments

Comments

@dan-da
Copy link
Contributor

dan-da commented Oct 24, 2021

I am making this issue as a place to temporarily drop some payments code/idea, since we don't have a module/crate for it yet.

In the real world, there is cash, and then there are wallets, cash registers, invoices, contracts, payments, receipts, etc that represent infrastructure built around the cash to facilitate its use and transfer. The infrastructure is separate from the cash and is normally created/provided by parties other than the cash issuer (ie mint, central bank).

I think of DBCs as the coins/cash equivalent base layer.

So I feel it will be cleanest if we enforce a similar separation/firewall between our "cash" and our payments infrastructure. For one thing, this keeps the footprint of the cash layer smaller, and thus easier to review/audit. It also may open the door for 3rd parties to provide alternative payment infrastructure more easily. Let 1000 flowers bloom.

I think a good approach would be to keep sn_dbc for the dbc/cash, and then make sn_payment (or maybe sn_dbc_payment) for the infrastructure around it. We could (possibly) keep both sn_dbc and sn_payment in the same github repo, so that the crates are more tightly bound together when making changes. Actually, I'd prefer not to do this, as it also binds together issues, pull requests, etc. But we could discuss about it.

Anyway, here is the payments data structures that we came up with in a recent meeting.

// seller commits to a price.
struct Invoice {
    amount: Amount
    payto: PublicKey,
    seller_signature: Signature,
}

// buyer pays it.
struct PaidInvoice {
    invoice: Invoice,
    payment: Payment,
}

// A payment looks like
pub struct Payment {
    dbc_packets: Vec<DbcPacket>,
    memo: Vec<u8>,    // should be fixed size?
}

// public bulletin board,
// sender puts Invoice + Dbcs up on bulletin board.
// shows that sender made payment.  (without obtaining a receipt)


// Requires interaction/trust.  atomic swap protocol?
// struct PaymentReceipt {
//     payment: 
//     signature: 
// }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@dan-da and others