Commit f072bb89 authored by Daniel Edgecumbe's avatar Daniel Edgecumbe

Add a crappy interface for constructing PSBTs

parent c6c91081
Pipeline #309 passed with stages
in 28 seconds
......@@ -198,6 +198,55 @@ along with bitcoin-top. If not, see <http://www.gnu.org/licenses/>.
<template v-if="unused_address">
<span class="waladdr">{{ unused_address }}</span>
</template>
<template v-if="walletinfo">
<h2>send some bitcoins</h2>
<span>address</span>
<input
id="wallet_send_address"
type="text"
v-model="wallet_send_address"
v-on:change="submitCreatePSBT()"
>
</input>
<span>amount</span>
<input
id="wallet_send_amount"
type="text"
v-model="wallet_send_amount"
v-on:input="submitCreatePSBT()"
>
</input>
<span>feerate</span>
<input
id="wallet_send_feerate"
type="text"
v-model="wallet_send_feerate"
v-on:input="submitCreatePSBT()"
>
</input>
</template>
<template v-if="wallet_createpsbt">
<div id="wallet_createpsbt" style="font-family: monospace;">
<span>Fee: {{ wallet_createpsbt.fee }}</span>
<span
v-for="input in wallet_createpsbt.inputs"
>
in {{ input.witness_utxo.amount }}: {{ input.witness_utxo.scriptPubKey.address }}
</span>
<span
v-for="vout in wallet_createpsbt.tx.vout"
>
<template v-if="vout.n === wallet_createpsbt.changepos">
out CHANGE: {{ vout.value }}: {{ vout.scriptPubKey.addresses[0] }}
</template>
<template v-else>
out {{ vout.value }}: {{ vout.scriptPubKey.addresses[0] }}
</template>
</div>
</template>
</div>
<div id="txtable">
<template v-if="transactions">
......
......@@ -120,6 +120,10 @@ onload = function() {
blocktemplate: null,
unused_address: null,
unused_address_qr: null,
wallet_send_address: null,
wallet_send_amount: 0.05,
wallet_send_feerate: 0.00001,
wallet_createpsbt: null,
transactions: null,
git_status: null,
authors_md: null,
......@@ -131,7 +135,7 @@ onload = function() {
datas: DATAS,
range: 0,
ranges: RANGES,
tab: "dashboard",
tab: "wallet",
tabs: TABS,
blocks: {},
staging: window.location.host.includes("test"),
......@@ -184,6 +188,19 @@ onload = function() {
},
},
methods: {
submitCreatePSBT: function() {
let l = [
"createpsbt",
app.wallet_send_address,
app.wallet_send_amount,
app.wallet_send_feerate,
];
for (let x of l) {
if (x === null) { console.log(l); return; }
}
let request = l.join("/");
asyncRequest(request, dealWithCreatePSBT);
},
submitDebugInput: function() {
let request = app.debug_input.split(" ").join("/");
asyncRequest(request, dealWithDebugOutput);
......@@ -307,6 +324,26 @@ onload = function() {
asyncRequest(`nettotalsrange/${range}`, processAsyncResponse);
}
let dealWithCreatePSBT = function(r, j) {
// TODO: it should really be result, error
// so that we can nuke this on a bad
app.wallet_createpsbt = j;
let fee = j.fee;
let changepos = j.changepos;
for (let input of j.inputs) {
// TODO does this assume segwit?
let inamt = input.witness_utxo.amount;
let inaddr = input.witness_utxo.scriptPubKey.address;
console.log(inamt, inaddr);
}
for (let vout of j.tx.vout) {
let outamt = vout.value;
let outaddr = vout.scriptPubKey.addresses[0];
if (vout.n == changepos) { console.log("CHANGE", outamt, outaddr); }
else { console.log(outamt, outaddr); }
}
}
let dealWithDebugOutput = function(r, j) {
let jj = j.result;
if (jj === null) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment