def listunspent(self, minconf=0, maxconf=9999999, addrs=None):
        """Return unspent transaction outputs in wallet

        Outputs will have between minconf and maxconf (inclusive)
        confirmations, optionally filtered to only include txouts paid to
        addresses in addrs.
        """
        r = None
        if addrs is None:
            r = self._call('listunspent', minconf, maxconf)
        else:
            addrs = [str(addr) for addr in addrs]
            r = self._call('listunspent', minconf, maxconf, addrs)

        r2 = []
        for unspent in r:
            unspent['outpoint'] = COutPoint(lx(unspent['txid']), unspent['vout'])
            del unspent['txid']
            del unspent['vout']

            # address isn't always available as Ravencoin Core allows scripts w/o
            # an address type to be imported into the wallet, e.g. non-p2sh
            # segwit
            try:
                unspent['address'] = CRavencoinAddress(unspent['address'])
            except KeyError:
                pass
            unspent['scriptPubKey'] = CScript(unhexlify(unspent['scriptPubKey']))
            unspent['amount'] = int(unspent['amount'] * COIN)
            r2.append(unspent)
        return r2
Beispiel #2
0
def validate_address(addr):
    try:
        CRavencoinAddress(addr)
        result = True
    except Exception:
        result = False
    return result
    def getrawchangeaddress(self):
        """Returns a new Ravencoin address, for receiving change.

        This is for use with raw transactions, NOT normal use.
        """
        r = self._call('getrawchangeaddress')
        return CRavencoinAddress(r)
 def validateaddress(self, address):
     """Return information about an address"""
     r = self._call('validateaddress', str(address))
     if r['isvalid']:
         r['address'] = CRavencoinAddress(r['address'])
     if 'pubkey' in r:
         r['pubkey'] = unhexlify(r['pubkey'])
     return r
 def getnewaddress(self):
     """
     Construct a new address based on a passphrase template. As more
     addresses are generated, the template value goes up.
     """
     passphrase = self._getnewaddress_passphrase_template.format(self._getnewaddress_offset)
     address = make_address_from_passphrase(bytes(passphrase, "utf-8"))
     self._getnewaddress_offset += 1
     return CRavencoinAddress(address)
    def getnewaddress(self, account=None):
        """Return a new Ravencoin address for receiving payments.

        If account is not None, it is added to the address book so payments
        received with the address will be credited to account.
        """
        r = None
        if account is not None:
            r = self._call('getnewaddress', account)
        else:
            r = self._call('getnewaddress')

        return CRavencoinAddress(r)
def make_txout(amount=None, address=None, counter=None):
    """
    Make a CTxOut object based on the parameters. Otherwise randomly generate a
    CTxOut to represent a transaction output.

    :param amount: amount in satoshis
    """
    passphrase_template = "correct horse battery staple txout {counter}"

    if not counter:
        counter = random.randrange(0, 2**50)

    if not address:
        passphrase = passphrase_template.format(counter=counter)
        address = make_address_from_passphrase(bytes(passphrase, "utf-8"))

    if not amount:
        maxsatoshis = (21 * 1000 * 1000) * (100 * 1000 * 1000) # 21 million BTC * 100 million satoshi per BTC
        amount = random.randrange(0, maxsatoshis) # between 0 satoshi and 21 million BTC

    txout = CMutableTxOut(amount, CRavencoinAddress(address).to_scriptPubKey())

    return txout
 def getaccountaddress(self, account=None):
     """Return the current Ravencoin address for receiving payments to this
     account."""
     r = self._call('getaccountaddress', account)
     return CRavencoinAddress(r)
Beispiel #9
0

def burn(s):
    decoded = b58dc(s, trim=4)
    decoded_hex = binascii.hexlify(decoded)
    check = hh256(decoded)[:8]
    coded = decoded_hex + check
    return b58ec(coded)


if __name__ == "__main__":
    args = parser.parse_args()
    template = args.template
    if template[0] != "R":
        raise AlphabetError("Template must begin with the letter R")
    for c in template:
        if c not in ABET:
            raise AlphabetError("Character {} is not valid base58.".format(c))
        tlen = len(template)
        if tlen < 34:
            template = template + ((34 - tlen) * "X")
        else:
            template = template[:34]
    try:
        burn_address = CRavencoinAddress(burn(template))
        print(burn_address)
    except CRavencoinAddressError:
        print(
            "'{}' is not a valid template (Must begin with the letter R followed by a capital letter e.g. 'RV')"
            .format(args.template))