Author

Topic: lock and vout (Read 1618 times)

hero member
Activity: 725
Merit: 503
August 03, 2015, 12:17:25 PM
#17
Ok, that could be a quick fix but I'm really trying to fix it in my online wallet for others to use too (see signature) and learn bitcoin well enough to ultimately build my own truly scalable "instant confirmation transactions" and "completely anonymous" crypto currency.

bitcoind is dragging it's feet but if it has any problems; it's the problems of the entire bitcoin network.

If I use some hacked together wallet and there is some problem, it's basically my own fault.

If you want to take care of others money that's not responsible.

Will check out "coin control" though.
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
August 03, 2015, 05:01:56 AM
#16
Also I'm bitcoind centric, because other wallets might have bugs or get compromised and really are a waste of time.

I think that "bitcoind" has actually dragged its feet compared to other wallets mostly because the devs opinion is that other wallets *should* be preferred (and "bitcoind" more and more being targeted towards non-wallet users).

But even if sticking with Bitcoin Core - isn't it possible to lock/unlock UTXOs via the "coin control" feature in the "bitcoin-qt" wallet UI?
hero member
Activity: 725
Merit: 503
August 03, 2015, 04:39:43 AM
#15
Yeah, two wallets was an option when the requirements were low, memory usage and leaks, bandwidth, security, backup, etc. etc.

Yes, multiwallet systems would work but now it's too late, I have a wallet that has mixed unspent outputs and I need to separate them and I want to see if I can solve this problem for others too permanently.

Also I'm bitcoind centric, because other wallets might have bugs or get compromised and really are a waste of time.
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
August 03, 2015, 04:35:50 AM
#14
You can *use* offline storage but admittedly it is a little more effort and typically involves having to do raw transactions.

Another more simple approach you could use is to have two different wallets - I forget whether there is a command-line option to choose a wallet directory but otherwise you could probably whip up some sort of script that copies the wallet contents before starting bitcoind.

There are also "other clients" that actually do give you multiple wallets (so maybe consider changing to one of those).
hero member
Activity: 725
Merit: 503
August 03, 2015, 04:23:24 AM
#13
Well, I want to be able to use them, that's kinda the whole point, money that can't be used is meaningless... The problem is that bitcoin is hiding how it really works to be "user friendly" but really that works against it in the long run because nobody is auditing and criticizing these parts that are really "complex" and "limiting"...

The really crazy part is that accounts are completely botched, spending outputs across account borders, you can't control which outputs are being spent... which creates a horrible problem leading to raw transactions being the only solution in a multiple account system.

Really rendering off-chain transactions useless! :0
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
August 03, 2015, 04:18:35 AM
#12
I see - have you not considered perhaps using "watch only addresses" and keeping your "more private" private keys completely offline (therefore impossible for bitcoind to accidentally use)?
hero member
Activity: 725
Merit: 503
August 03, 2015, 04:11:37 AM
#11
So that I can control anonymity, I do not want my bitcoind to inadvertently mix public (as in connected to my real name that the "IRS" can see because I bought them from an exchange where they require KYC) and my private (that I mined and want to keep "unprovably mine") in the event of my government making owning bitcoin illegal or tax them without them being spent.

Code:
JSONObject tx = bitcoin().getTransaction(trans.getString("txid"));
String address = tx.getJSONArray("details").getJSONObject(0).getString("address");
JSONObject raw = bitcoin().decodeRawTransaction(tx.getString("hex"));
JSONArray out = raw.getJSONArray("vout");

for(int j = 0; j < out.length(); j++) {
JSONObject vout = out.getJSONObject(j);
JSONArray addresses = vout.getJSONObject("scriptPubKey").getJSONArray("addresses");

for(int k = 0; k < addresses.length(); k++) {
String dest = addresses.optString(k);

if(dest.equals(address)) {
System.out.println("vout " + vout.getInt("n"));
}
}
}

Code like this really shows how far bitcoin still has to go...

I'm surprised you are asking why this is needed, how are you keeping your transactions "anonymous"?

----

Second follow up Q:

The details is an array, what can one expect there?

scriptPubKey.addresses is also an array, can an output be sent to multiple addresses?!?!?!?
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
August 03, 2015, 03:57:59 AM
#10
So I simply loop through vout and look at the scriptPubKey.addresses to see if the destination address is in there then add that to vout in lockunspent?

If your requirement is to lock each output (that matches an address) for a given tx then yes that would be they way to do it (although I don't know why you are wanting to do this).
hero member
Activity: 725
Merit: 503
August 03, 2015, 03:54:43 AM
#9
So I simply loop through vout and look at the scriptPubKey.addresses to see if the destination address is in there then add that to vout in lockunspent?
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
August 03, 2015, 03:54:06 AM
#8
Can one transaction create multiple outputs that you own? How does that even work!?

A typical tx you create will only have (at most) one output that you own (for change) but of course if txs are being created manually or via some special kind of script then anything is possible (and even without doing anything tricky there is nothing to stop you from creating a tx with multiple outputs where every address is actually one of your own rather than someone else's).
hero member
Activity: 725
Merit: 503
August 03, 2015, 03:05:08 AM
#7
I'll look into it, still if I want to lock the whole transaction it seems very unnecessary to have to decode stuff and loop through everything...

Edit: Ok thx, decoderawtransaction works, but holy moly thats alot of work...

Can one transaction create multiple outputs that you own? How does that even work!?

---

Followup Q:

So I simply look at the scriptPubKey.addresses to see if the destination address is in there then add that to vout in lockunspent?
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
August 03, 2015, 03:00:00 AM
#6
I can't see vout on any of my transactions... Having to code something that is only there sometimes is really bad.

It's always there (even if there is only one output).

Have you tried using "decoderawtransaction"?
hero member
Activity: 725
Merit: 503
August 03, 2015, 02:58:09 AM
#5
Basically how can I extract the info I need to provide to lockunspent?

I can't see vout on any of my transactions... Having to code something that is only there sometimes is really bad.

listTransactions

then

getTransaction

do I need to getrawtransaction to se UTXO?

So then I need to set the -txindex flag?
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
August 03, 2015, 02:57:33 AM
#4
If the tx only contains one output then just use 0 but do remember that txs will often have a "change" output (so not that often that a tx has only one output).

If you know the txid then you can "decoderawtransaction" to see all the inputs and outputs.
hero member
Activity: 725
Merit: 503
August 03, 2015, 02:52:56 AM
#3
Ok, I get that it's important but if I just want to lock a complete transaction I shouldn't have to supply it? Specially when I don't know how to retrieve it, seems it's only present in transactions that have multiple outputs?

But what does the number refer to? The pointer in an array for each transaction? I have googled and that number is sometimes 1222 or something large like that; does that mean there are 1222 output minimum in that transaction? Just trying to wrap my head around this hidden complexity.

Basically how can I extract the info I need to provide to lockunspent?
legendary
Activity: 1890
Merit: 1086
Ian Knowles - CIYAM Lead Developer
August 03, 2015, 02:50:07 AM
#2
All UTXOs have a "vout" so assuming the "lockunspent" is actually locking a UTXO it would require that to be provided (unless the command has been designed to lock *all* UTXOs tied to the same tx if no explicit vout is provided).

When you create a Bitcoin tx one or more UTXOs (Unspent Transaction Outputs) are the "inputs" with the "outputs" becoming new UTXOs created by the transaction.

Understanding UTXOs is a fundamental part of understanding how Bitcoin works (so do take the time to study this if you are not 100% sure of it).
hero member
Activity: 725
Merit: 503
August 03, 2015, 02:46:23 AM
#1
Does lockunspent require vout?

Do all transactions have vout?

How can I see vout?

Is 0 the default vout?

What is vout?

In the documentation is says: (numeric) The output number -- eh, ok?
Jump to: