[ad_1]
The steps i adopted are i first load the pockets in a unique technique which works, then i test the steadiness of the pockets in a unique technique which works, after which I name this sendbitcoin technique(under). I can see that the bitcoind server will get the message however it returns with a 500.
If i take advantage of bitcoin-cli it really works nevertheless i would like so as to add a -rpcwallet flag. It is my understanding that because the pockets has been loaded i should not want to make use of flag. My wallets aren’t encrypted so i do not imagine i would like to make use of a passphrase.
My bitcoin.conf file seems to be like this.
rpcuser=rpcuser
rpcpassword=rpcpassword
testnet=1
prune=550
server=1
dbcache=1000
[test]
debug=mempool
debug=rpc
dbcache=1000
rpcport=8332
rpcbind=0.0.0.0
rpcallowip=172.19.0.0/16
minconf=1
fallbackfee=0.00000001
And the tactic seems to be like.
func (w *Pockets) SendBitcoin(sendTo string, quantity float64, coachID uint) (BitcoinTransaction, error) {
username := os.Getenv("RPC_USER")
password := os.Getenv("RPC_PASSWORD")
rpcURL := os.Getenv("BITCOIN_NODE_HOST")
if username == "" || password == "" || rpcURL == ""
log.Error("RPC_USER, RPC_PASSWORD, or BITCOIN_NODE_HOST setting variables usually are not set")
return BitcoinTransaction, errors.New("RPC_USER, RPC_PASSWORD, or BITCOIN_NODE_HOST setting variables usually are not set")
// Put together the RPC request payload
requestBody := map[string]interface
"jsonrpc": "1.0",
"technique": "sendtoaddress",
"params": []interfacesendTo, quantity,
"id": 1,
logrus.Printf("request physique : %v", requestBody)
logrus.Printf("Sending on pockets %v", w.Identify)
jsonData, err := json.Marshal(requestBody)
if err != nil
log.Errorf("didn't marshal JSON request: %v", err)
return BitcoinTransaction, fmt.Errorf("didn't marshal JSON request: %v", err)
logrus.Printf("JSON physique : %v", jsonData)
consumer := &http.Consumer
req, err := http.NewRequest("POST", rpcURL, bytes.NewBuffer(jsonData))
if err != nil
log.Errorf("didn't create HTTP request: %v", err)
return BitcoinTransaction, fmt.Errorf("didn't create HTTP request: %v", err)
req.SetBasicAuth(username, password)
req.Header.Set("Content material-Kind", "software/json")
// Ship HTTP request
resp, err := consumer.Do(req)
if err != nil
log.Errorf("didn't ship HTTP request: %v", err)
return BitcoinTransaction, fmt.Errorf("didn't ship HTTP request: %v", err)
//...
logs
[00] bitcoin | 2024-02-22T22:36:59Z [rpc] ThreadRPCServer
technique=loadwallet person=rpcuser
[00] rest-server | time="2024-02-22T22:36:59Z" degree=information msg="steadiness
= 0.0003933699999999999, quantity = 0.0001"
[00] bitcoin | 2024-02-22T22:36:59Z Utilizing SQLite Model 3.38.5
[00] bitcoin | 2024-02-22T22:36:59Z Utilizing pockets
/residence/bitcoin/.bitcoin/testnet3/wallets/111-20240221
[00] bitcoin | 2024-02-22T22:36:59Z [rpc] ThreadRPCServer
technique=sendtoaddress person=rpcuser
[00] rest-server | time="2024-02-22T22:36:59Z" degree=information msg="request
physique : map[id:1 jsonrpc:1.0 method:sendtoaddress params:
[tb1qljunwv4hv8nx3mwsrup4fse5zhahyjtmx0fwzl 0.0001 ]]"
[00] rest-server | time="2024-02-22T22:37:00Z" degree=information
msg="sudden standing code: 500"
[ad_2]
Supply hyperlink
Leave a Reply