fedimint / fedimint-clientd

MIT License
13 stars 14 forks source link

Successful payments return amount #26

Closed 448-OG closed 1 month ago

448-OG commented 4 months ago

On successful payment instead of returning InfoResponse we now return fedimint_core::Amount in functions:

Other functions or methods that return info reponse in a manner that requires detailed information like _info in the router/handlers/fedimint/admin/info.rs have not been modified as I assume all the information is InfoResponse is required.

Resolves: #19

Kodylow commented 4 months ago

Approach nit: it'd be better to align with something like LNURLPay or give more info on the payment itself besides just the amount. https://github.com/lnurl/luds/blob/legacy/lnurl-pay.md

Alby's "verify" url that they do for LNURLPay payments is generally pretty great, it'll return this for success:

{
status: "OK",
settled: true,
preimage: "0a7c619cc24bfbcc5be36ffc9b22a1517be1ec18b59deef2022eea679fa83109",
pr: "lnbc10n1pnzqg55pp5vvm6vl3s463q4xqd09cyw8t84fjkc36e95hvatn9ng9wr46x339shp56kymqtxr5es99pd82vjjnmssr2l72l379pv87d05c5pd4s2n0ysqcqzzsxqyz5vqsp549eq3383snqkapycuv99yjhzheldz40el8hpuyftut60v5q9kaus9qyyssqx58c5tged0nhz5n4czyg9d9a94z6xh325hsj5dkjd49hduqka3hx095lscgeuatzyqstwayucmwt3qf8njgk6gqzz7p4v0jles78xkcpkx43c4"
}

or this for unpaid:

{
status: "OK",
settled: false,
preimage: null,
pr: "lnbc10n1pnzqghjpp54ra8lw0tuap2wfza6tgjajkeye9pp54yne3y85gat62v7urd024qhp56kymqtxr5es99pd82vjjnmssr2l72l379pv87d05c5pd4s2n0ysqcqzzsxqyz5vqsp590alky2gx75407l3lc2mnge5a69f9a2qmywhq32jnug9gpt2w7as9qyyssqnmda9yf7ejey663dez5394dcnmxz88dxcxf90f68tsff4u2nf5mxvr72n30z27m24fggrmzkszukyum23tmv7hqfm4qwz6x8j0cewasqu9240c"
}

For our purposes we could return operationType and operationInfo instead of pr, but most importantly returning the status / settled similarly to above

448-OG commented 4 months ago

Where is OperationType and OperationInfo defined, I cant find any definition of which fields they might contain in the fedimint docs. While I can do something like

&client.operation_log().get_operation(req.operation_id).await.unwrap();

to get the OperationLogEntry , which has a method .outcome() which can be <OperationType>State or serde_json::Value , where is OperationType defined or if I parse to serde_json::Value , which data structure was serialized into the serde_json::Value in the first place ? So that I know which fields are contained in it? https://docs.rs/fedimint-client/latest/fedimint_client/oplog/struct.OperationLogEntry.html#method.outcome

448-OG commented 4 months ago

@Kodylow any updates on this

Kodylow commented 4 months ago

It depends on what you're looking up, what you probably want is to lookup the contract on the federation associated with that operation id