Bitcoin Forum
October 17, 2017, 04:39:38 PM *
News: Latest stable version of Bitcoin Core: 0.15.0.1  [Torrent]. (New!)
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: lock and vout  (Read 1392 times)
rupy
Hero Member
*****
Offline Offline

Activity: 725



View Profile
August 03, 2015, 07: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?

BANKBOOK GWT Wallet & no-FIAT Billing API
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1508258378
Hero Member
*
Offline Offline

Posts: 1508258378

View Profile Personal Message (Offline)

Ignore
1508258378
Reply with quote  #2

1508258378
Report to moderator
1508258378
Hero Member
*
Offline Offline

Posts: 1508258378

View Profile Personal Message (Offline)

Ignore
1508258378
Reply with quote  #2

1508258378
Report to moderator
CIYAM
Legendary
*
Offline Offline

Activity: 1862


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 03, 2015, 07: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).

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
rupy
Hero Member
*****
Offline Offline

Activity: 725



View Profile
August 03, 2015, 07: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?

BANKBOOK GWT Wallet & no-FIAT Billing API
CIYAM
Legendary
*
Offline Offline

Activity: 1862


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 03, 2015, 07: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.

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
rupy
Hero Member
*****
Offline Offline

Activity: 725



View Profile
August 03, 2015, 07: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?

BANKBOOK GWT Wallet & no-FIAT Billing API
CIYAM
Legendary
*
Offline Offline

Activity: 1862


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 03, 2015, 08: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"?

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
rupy
Hero Member
*****
Offline Offline

Activity: 725



View Profile
August 03, 2015, 08: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?

BANKBOOK GWT Wallet & no-FIAT Billing API
CIYAM
Legendary
*
Offline Offline

Activity: 1862


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 03, 2015, 08: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).

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
rupy
Hero Member
*****
Offline Offline

Activity: 725



View Profile
August 03, 2015, 08: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?

BANKBOOK GWT Wallet & no-FIAT Billing API
CIYAM
Legendary
*
Offline Offline

Activity: 1862


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 03, 2015, 08: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).

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
rupy
Hero Member
*****
Offline Offline

Activity: 725



View Profile
August 03, 2015, 09: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?!?!?!?

BANKBOOK GWT Wallet & no-FIAT Billing API
CIYAM
Legendary
*
Offline Offline

Activity: 1862


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 03, 2015, 09: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)?

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
rupy
Hero Member
*****
Offline Offline

Activity: 725



View Profile
August 03, 2015, 09: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

BANKBOOK GWT Wallet & no-FIAT Billing API
CIYAM
Legendary
*
Offline Offline

Activity: 1862


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 03, 2015, 09: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).

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
rupy
Hero Member
*****
Offline Offline

Activity: 725



View Profile
August 03, 2015, 09: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.

BANKBOOK GWT Wallet & no-FIAT Billing API
CIYAM
Legendary
*
Offline Offline

Activity: 1862


Ian Knowles - CIYAM Lead Developer


View Profile WWW
August 03, 2015, 10: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?

With CIYAM anyone can create 100% generated C++ web applications in literally minutes.

GPG Public Key | 1ciyam3htJit1feGa26p2wQ4aw6KFTejU
rupy
Hero Member
*****
Offline Offline

Activity: 725



View Profile
August 03, 2015, 05: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.

BANKBOOK GWT Wallet & no-FIAT Billing API
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!