1package Finance::Bitcoin::Address; 2 3BEGIN { 4 $Finance::Bitcoin::Address::AUTHORITY = 'cpan:TOBYINK'; 5 $Finance::Bitcoin::Address::VERSION = '0.902'; 6} 7 8use 5.010; 9use Moo; 10use Carp; 11use Finance::Bitcoin; 12use Scalar::Util qw( blessed ); 13 14with "Finance::Bitcoin::Role::HasAPI"; 15 16has address => (is => "ro"); 17 18sub label 19{ 20 my $self = shift; 21 $self->api->call(setlabel => $self->address, @_) if @_; 22 return $self->api->call(getlabel => $self->address); 23} 24 25sub received 26{ 27 my $self = shift; 28 my ($minconf) = @_; 29 return $self->api->call(getreceivedbyaddress => $self->address, ($minconf//1)); 30} 31 321; 33 34__END__ 35 36=head1 NAME 37 38Finance::Bitcoin::Address - a bitcoin address 39 40=head1 SYNOPSIS 41 42 use Finance::Bitcoin; 43 44 my $uri = 'http://user:password@127.0.0.1:8332/'; 45 my $wallet = Finance::Bitcoin::Wallet->new($uri); 46 47 foreach my $address ($wallet->addresses) 48 { 49 print $address->address . "\n"; 50 print $address->label . "\n"; 51 print $address->received . "\n\n"; 52 } 53 54=head1 DESCRIPTION 55 56This module is part of the high-level API for accessing a running 57Bitcoin instance. 58 59=over 4 60 61=item C<< new($endpoint, $string) >> 62 63Constructor. $endpoint may be the JSON RPC endpoint URL, or may be a 64Finance::Bitcoin::API object; $string is an address string. 65 66=begin trustme 67 68=item BUILDARGS 69 70=end trustme 71 72=item C<< address >> 73 74Returns the address string. 75 76=item C<< label >> 77 78Get/set the address label. 79 80=item C<< received($minconf) >> 81 82Returns the total amount received via this address, with at least $minconf 83confirmations. $minconf defaults to 1. 84 85=item C<< api >> 86 87Retrieve a reference to the L<Finance::Bitcoin::API> object being used. 88 89=back 90 91=head1 BUGS 92 93Please report any bugs to L<http://rt.cpan.org/>. 94 95=head1 SEE ALSO 96 97L<Finance::Bitcoin>, L<Finance::Bitcoin::Wallet>. 98 99L<http://www.bitcoin.org/>. 100 101=head1 AUTHOR 102 103Toby Inkster E<lt>tobyink@cpan.orgE<gt>. 104 105=head1 COPYRIGHT 106 107Copyright 2010, 2011, 2013, 2014 Toby Inkster 108 109This library is free software; you can redistribute it and/or modify it 110under the same terms as Perl itself. 111 112=head1 DISCLAIMER OF WARRANTIES 113 114THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED 115WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 116MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. 117