gcash / bchwallet

A secure bitcoin cash wallet daemon written in Go (golang)
ISC License
43 stars 29 forks source link

Support for protobuf over HTTP? #68

Closed Ekliptor closed 3 years ago

Ekliptor commented 4 years ago

I made a small fork of bchwallet and added a proof-of-concept to integrate it into PHP/WordPress on shared hosting providers.

See the README for an explanation of the current PHP problems and possible solutions: https://github.com/Ekliptor/bchwallet

We (James Cramer and me need a solution to integrate bchwallet into WordPress) as the current rest.bitcoin.com solution is not reliable enough

Projects: https://wordpress.org/plugins/slp-payments-for-woocommerce/ http://cashtippr.com/

I am open for better ideas.

cpacia commented 4 years ago

Do you want to use gRPC web? We could rig the bchwallet to use that as well. It currently does not.

Ekliptor commented 4 years ago

I think gRPC web will be an improvement for clients using bchwallet from the browser.

For this issue, it will not bring bchwallet closer to PHP shared hosting plans. gRPC Web is a proxy in front of the TCP-based gRPC service to allow access via HTTP. There are no libraries written in "real" PHP (without C) implementing gRPC Web neither. Although I honestly haven't looked at the exact spec - it might be less work to implement gRPC Web than writing a full-blown gRPC TCP client in PHP (gRPC Web has less features, no bi-directional streams etc...)

jcramer commented 4 years ago

Does this fit the bill? I've used it on another project and it works pretty well.

https://github.com/grpc-ecosystem/grpc-gateway

Ekliptor commented 4 years ago

Yes I just tested it and it is perfect for our use-case.

grpc-web would still require us to write a grpc client in PHP (there currently is only 1 in JavaScript for browsers) to use grpc: https://github.com/grpc/grpc-web

The gateway you linked is a real gRPC <-> HTTP REST API gateway, thus removing any grpc client-state etc.. (and possibly some features). So we can use this with built-in WordPress HTTP functions

edit: example (only this method added yet): http://bchd.cashtippr.com:8081/v1/bchrpc/GetMempool/full_transactions/1

requires .proto file to be modified slightly:

    rpc GetMempool(GetMempoolRequest) returns (GetMempoolResponse) {
        option (google.api.http) = {
        get: "/v1/bchrpc/GetMempool"
        additional_bindings: {
            get: "/v1/bchrpc/GetMempool/full_transactions/{full_transactions}",
        }
        };
    }

vs the GRPC-web node that supports all API calls without .proto modifications: https://bchd.cashtippr.com:9000

Ekliptor commented 3 years ago

solved by adding support the grpc-gateway James suggested https://bchd.ny1.simpleledger.io/