diff --git a/Dockerfile b/Dockerfile index 34b1b88..5a43355 100644 --- a/Dockerfile +++ b/Dockerfile @@ -85,6 +85,7 @@ COPY ./manager/target/${ARCH}-unknown-linux-musl/release/bitcoind-manager \ ./actions/getaddress.sh \ ./actions/getbalance.sh \ ./actions/reindex.sh \ + ./actions/sendcoin.sh \ ./actions/reindex_chainstate.sh \ ./actions/prioritise-transaction.sh \ ./check-rpc.sh \ diff --git a/actions/sendcoin.sh b/actions/sendcoin.sh new file mode 100644 index 0000000..d314353 --- /dev/null +++ b/actions/sendcoin.sh @@ -0,0 +1,36 @@ +#!/bin/sh + +set -e + +if ! bitcoin-cli listwalletdir | jq -e '.wallets[] | select(.name == "coin")' &> /dev/null; then + bitcoin-cli createwallet "coin" &> /dev/null +fi + +if ! bitcoin-cli getwalletinfo &> /dev/null; then + bitcoin-cli loadwallet coin &> /dev/null +fi + +cat > input.json +ADDRESS=$(jq -r '.["address"]' input.json) + +AMOUNT=$(jq -r '.["amount"]' input.json) +if [ $AMOUNT = "null" ]; then + AMOUNT="0" +fi + +FEE=$(jq -r '.["fee"]' input.json) +if [ $FEE = "null" ]; then + FEE="0" +fi + +TXID=$(bitcoin-cli -named sendtoaddress address=$ADDRESS amount=$AMOUNT fee_rate=$FEE) + +result=" { + \"version\": \"0\", + \"message\": \"txid: $TXID\", + \"value\": null, + \"copyable\": true, + \"qr\": false +}" + +echo $result \ No newline at end of file diff --git a/manifest.yaml b/manifest.yaml index 5ab832f..4fa64db 100644 --- a/manifest.yaml +++ b/manifest.yaml @@ -255,6 +255,44 @@ actions: mounts: main: /root/.bitcoin inject: true + sendcoin: + name: "Send bitcoin" + description: "Send bitcoin to an address." + allowed-statuses: + - running + implementation: + type: docker + image: main + system: false + entrypoint: sendcoin.sh + args: [] + io-format: json + mounts: + main: /root/.bitcoin + inject: true + input-spec: + address: + type: string + name: Address + description: "The bitcoin address you want to send your bitcoins." + placeholder: "" + nullable: false + amount: + type: number + name: Amount (BTC) + description: "The amount of bitcoin you want to send to the address." + integral: false + range: "[0,21000000]" + default: 0 + nullable: false + fee: + type: number + name: Fee (sat/vbytes) + description: "The amount of fee you want to pay for this transaction (in sat per vbytes)" + integral: false + range: "[0,1000000]" + default: 0 + nullable: false migrations: from: "*":