mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-04-09 22:37:47 +08:00
62 lines
1.9 KiB
Python
62 lines
1.9 KiB
Python
#!/usr/bin/env python
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
Blockstack
|
|
~~~~~
|
|
copyright: (c) 2014-2015 by Halfmoon Labs, Inc.
|
|
copyright: (c) 2016 by Blockstack.org
|
|
|
|
This file is part of Blockstack
|
|
|
|
Blockstack is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
Blockstack is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
You should have received a copy of the GNU General Public License
|
|
along with Blockstack. If not, see <http://www.gnu.org/licenses/>.
|
|
"""
|
|
|
|
from ..nameset import NAMEREC_FIELDS
|
|
|
|
# consensus hash fields (ORDER MATTERS!)
|
|
FIELDS = NAMEREC_FIELDS + [
|
|
'name_hash', # hash(name)
|
|
'consensus_hash', # consensus hash when this operation was sent
|
|
'keep_data' # whether or not to keep the profile data associated with the name when transferred
|
|
]
|
|
|
|
def get_transfer_recipient_from_outputs( outputs ):
|
|
"""
|
|
Given the outputs from a name transfer operation,
|
|
find the recipient's script hex.
|
|
|
|
By construction, it will be the first non-OP_RETURN
|
|
output (i.e. the second output).
|
|
|
|
This also applies to a NAME_IMPORT.
|
|
"""
|
|
|
|
ret = None
|
|
for output in outputs:
|
|
|
|
output_script = output['scriptPubKey']
|
|
output_asm = output_script.get('asm')
|
|
output_hex = output_script.get('hex')
|
|
output_addresses = output_script.get('addresses')
|
|
|
|
if output_asm[0:9] != 'OP_RETURN' and output_hex:
|
|
|
|
ret = output_hex
|
|
break
|
|
|
|
if ret is None:
|
|
raise Exception("No recipients found")
|
|
|
|
return ret
|
|
|